Skip to content

Instantly share code, notes, and snippets.

@yelouafi
Created July 17, 2015 02:45
Show Gist options
  • Save yelouafi/ae5e18720dce28f4a0c6 to your computer and use it in GitHub Desktop.
Save yelouafi/ae5e18720dce28f4a0c6 to your computer and use it in GitHub Desktop.
// mergeMap : (Stream a, a -> Stream b) => Stream b
Stream.prototype.mergeMap = function(f) {
return this.map(f).mergeAll();
}
// example : log messages from a chat room
// login user returns a stream of messages from a logged user
loginUser : (name, password) -> Stream String
button.on('click').mergeMap( _ => loginUser(name, password) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment