Created
August 20, 2019 14:28
-
-
Save makomweb/4ddb4e2580ff4f62e8d0425c57febe77 to your computer and use it in GitHub Desktop.
simple script to run node js app with reactive extensions
This file contains hidden or 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 Rx = require('rx'); | |
const sequence = Rx.Observable.create(function(src) { | |
src.onNext(1); | |
src.onNext(2); | |
src.onNext(3); | |
src.onNext(4); | |
src.onError(new Error("booom!!!")); | |
src.onNext(5); | |
src.onCompleted(); | |
}); | |
/* | |
const sequence = Rx.Observable.just('hello'')); | |
const sequence = Rx.Observable.throw(new Error('boom!')); | |
*/ | |
sequence.subscribe( | |
msg => console.log(`message: ${msg}`), | |
ex => console.log(`error: ${ex}`), | |
() => console.log("finished!") | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment