Skip to content

Instantly share code, notes, and snippets.

@ruben-h
Forked from gsans/idle.js
Created December 17, 2015 13:02
Show Gist options
  • Save ruben-h/e363ee43e702f1261b86 to your computer and use it in GitHub Desktop.
Save ruben-h/e363ee43e702f1261b86 to your computer and use it in GitHub Desktop.
Idle user snippet
mergedStreams = rx.Observable.merge(
rx.DOM.keydown(document),
rx.DOM.click(document),
rx.DOM.mousemove(document),
rx.DOM.scroll(document),
rx.DOM.touchstart(document)
);
var idleStream = mergedStreams
.bufferWithTime(5000)
.filter(function(arr){
return arr.length===0;
})
.subscribe();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment