Skip to content

Instantly share code, notes, and snippets.

@erichulburd
Created December 23, 2017 00:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erichulburd/e0fbafc98d237237c28029f2fe70b71a to your computer and use it in GitHub Desktop.
Save erichulburd/e0fbafc98d237237c28029f2fe70b71a to your computer and use it in GitHub Desktop.
const game = (action$, store) =>
action$.ofType(actions.START)
.mergeMap(() => {
const interval = Observable.interval(250)
.takeUntil(action$.ofType(
actions.PAUSE,
actions.RESET,
actions.END
));
const incrementTime = interval
.map(_interval => actions.incrementTime());
const end = interval
// if the user has lost.
.map(_action => actions.end());
return Observable.merge(incrementTime, end);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment