Skip to content

Instantly share code, notes, and snippets.

@lafras
Created December 12, 2016 09:31
Show Gist options
  • Save lafras/c7179d9acf8ff962b1a11f2b72c4224e to your computer and use it in GitHub Desktop.
Save lafras/c7179d9acf8ff962b1a11f2b72c4224e to your computer and use it in GitHub Desktop.
Finally figured out this Reactive X subject thing...
import rx
obs = rx.Observable.range(0,10)
sub = rx.subjects.Subject()
square = sub.map(
lambda x: 'i am square: {}'.format(x**2)
)
cube = sub.map(
lambda x: 'i am cube: {}'.format(x**3)
)
square.subscribe(print)
cube.subscribe(print)
obs.subscribe(sub)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment