Created
November 14, 2018 10:11
-
-
Save nlharri/e568e0236fba0ec7ea9cf562e0436a64 to your computer and use it in GitHub Desktop.
RxJS Tutorial - Hello World!
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 } = require('rxjs'); | |
// Create an Observable | |
var observable = Observable.create((observer) => { | |
observer.next('Hello World!'); | |
observer.next('Hello Again!'); | |
observer.complete(); | |
observer.next('Bye'); // this will not be shown | |
}); | |
// Subscribe to the Observable, and print stream to the console | |
observable.subscribe( | |
(x) => console.log('next: ' + x), | |
(error) => console.log('error: ' + error), | |
() => console.log('completed') | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment