Created
October 18, 2019 18:00
-
-
Save traviskaufman/952b213fdcdfe98b63f02ff65436e47b to your computer and use it in GitHub Desktop.
Demystifying RxJS, Part I: Basic Observable Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const observable = new Observable(subscriber => { | |
subscriber.next(1); | |
subscriber.next(2); | |
subscriber.next(3); | |
setTimeout(() => { | |
subscriber.next(4); | |
subscriber.complete(); | |
}, 1000); | |
}); | |
console.log("just before subscribe"); | |
observable.subscribe( | |
x => { | |
console.log("got value " + x); | |
}, | |
err => { | |
console.error("something wrong occurred: " + err); | |
}, | |
() => { | |
console.log("done"); | |
} | |
); | |
console.log("just after subscribe"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment