Created
January 18, 2013 07:39
-
-
Save wolfflow/4562954 to your computer and use it in GitHub Desktop.
BaconJS activity/inactivity detection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
activity = $(document).asEventStream "keyup mousemove" | |
inactivity = activity.skipDuplicates().map((x)->x.timeStamp).toProperty("") | |
activity.subscribe(-> $("#test").show()) | |
inactivity.combine(inactivity.delay(1500), (a, b) -> a is b) | |
.filter((x)->x).subscribe(-> $("#test").hide()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment