Skip to content

Instantly share code, notes, and snippets.

@jordic
Last active December 14, 2016 06:13
Show Gist options
  • Save jordic/335869fb9af8ad3a0be4e83c50e3fb0b to your computer and use it in GitHub Desktop.
Save jordic/335869fb9af8ad3a0be4e83c50e3fb0b to your computer and use it in GitHub Desktop.
function fakeObservable(speed: number, num: number) {
return new Observable(obs => {
let t = setTimeout(() => {
console.log('next value:', num);
obs.next(num);
obs.complete();
}, speed);
// Cancelation
return () => {
console.log('cancelled', num);
clearTimeout(t);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment