Skip to content

Instantly share code, notes, and snippets.

@nelanka
Created February 13, 2015 15:18
Show Gist options
  • Save nelanka/32a0a82e6d30a2869d8b to your computer and use it in GitHub Desktop.
Save nelanka/32a0a82e6d30a2869d8b to your computer and use it in GitHub Desktop.
Scala RX Snippets
Add rx things together and log stuff:
(consumer.stream1 ++ consumer.stream2 ++ consumer.stream3).subscribe(event => logger.info("Received event " + event))
Filter out messages:
consumer.stream1.filter(_.isEnabled != true).subscribe(event => map.remove(event.id))
It’s kinda handy that rx streams are basically infinite lists that you can apply all scala magical collection incantations to.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment