Skip to content

Instantly share code, notes, and snippets.

@nlharri
Created November 14, 2018 10:11
Show Gist options
  • Save nlharri/e568e0236fba0ec7ea9cf562e0436a64 to your computer and use it in GitHub Desktop.
Save nlharri/e568e0236fba0ec7ea9cf562e0436a64 to your computer and use it in GitHub Desktop.
RxJS Tutorial - Hello World!
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