Skip to content

Instantly share code, notes, and snippets.

@tusharmath
Last active June 14, 2016 22:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tusharmath/86b37c3db77353b305547f88de949e30 to your computer and use it in GitHub Desktop.
Save tusharmath/86b37c3db77353b305547f88de949e30 to your computer and use it in GitHub Desktop.
Create coprophagus streams
const Rx = require('Rx')
const O = Rx.Observable
const R = require('ramda')
function SlimShady (signal$) {
return signal$
.delay(500).map((x) => x + 1)
}
const coprophagus = R.curry((funct, signal$) => {
const sub = new Rx.Subject()
const out$ = funct(O.merge(sub.asObservable(), signal$))
return out$.multicast(sub).refCount()
})
const slimShady = coprophagus(SlimShady)
slimShady(O.just(0))
.take(4)
.subscribe((x) => console.log(x))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment