Last active
September 14, 2016 06:53
-
-
Save BerkeleyTrue/27ed0c6870554905dfb2cbcd441da31f to your computer and use it in GitHub Desktop.
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
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