Skip to content

Instantly share code, notes, and snippets.

@thejohnfreeman
Last active January 9, 2019 21:41
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 thejohnfreeman/472bc0503eb35dc0ed34dcde65504404 to your computer and use it in GitHub Desktop.
Save thejohnfreeman/472bc0503eb35dc0ed34dcde65504404 to your computer and use it in GitHub Desktop.
function flow(makeGenerator) {
// Return a function that constructs an Observable.
return function(...args) {
return Observable.create(observer => {
// This function won't be called until the observable is subscribed.
const generator = makeGenerator.apply(this, args)
generator.next = action(generator.next)
generator.throw = action(generator.throw)
generator.return = action(generator.return)
return new GeneratorSubscriber(observer, generator)
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment