Skip to content

Instantly share code, notes, and snippets.

@CharlieHess
Created August 26, 2015 05:49
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 CharlieHess/b792e75789b2d6c40bb2 to your computer and use it in GitHub Desktop.
Save CharlieHess/b792e75789b2d6c40bb2 to your computer and use it in GitHub Desktop.
New Rx Hot Shit
let timeExpired = rx.Observable.timer(0, 1000, scheduler)
.take(timeout + 1)
.publishLast();
let newPlayers = messages.where(e => e.text && e.text.toLowerCase().match(/\byes\b/))
.map(e => e.user)
.distinct()
.take(maxPlayers)
.publish();
newPlayers.connect();
timeExpired.connect();
// Once our timer has expired, we're done accepting new players.
return newPlayers.takeUntil(timeExpired);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment