Skip to content

Instantly share code, notes, and snippets.

@BerkeleyTrue
Last active September 14, 2016 06:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save BerkeleyTrue/27ed0c6870554905dfb2cbcd441da31f to your computer and use it in GitHub Desktop.
Save BerkeleyTrue/27ed0c6870554905dfb2cbcd441da31f to your computer and use it in GitHub Desktop.
const logoutTime = 15* 60;
const warningTime = 14 * 60;
function createLogoutActionStream() {
return Observable.merge(
Observable.of({ type: 'showLogoutMessageWarning' }).delay(warningTime * 1000),
Observable.of({ type: 'logOut' }).delay(logoutTIme * 1000)
);
}
mouseEventStream
.startWith(null) // ensure starts at app boot instead of first mouse event
.flatMapLatest(createLogoutActionStream) // flatMapLatest will start timeout and reset with each new event
.doOnNext(dispatch); // dispatch actions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment