Skip to content

Instantly share code, notes, and snippets.

@wyeo
Created May 29, 2017 15:20
Show Gist options
  • Save wyeo/386fc4cdcbc0013f9066f77c323c5990 to your computer and use it in GitHub Desktop.
Save wyeo/386fc4cdcbc0013f9066f77c323c5990 to your computer and use it in GitHub Desktop.
Observable.interval = (period) => {
Observable.prototype.subscribe = (nextFn) => {
let i = 0
const timeout = setInterval((function(){ nextFn(i++) }), period)
return clearInterval.bind(null, timeout)
}
return new Observable()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment