Skip to content

Instantly share code, notes, and snippets.

@uk-ar
Created August 23, 2016 20:49
Show Gist options
  • Save uk-ar/09f901486c6ba138b451528bebf65dc7 to your computer and use it in GitHub Desktop.
Save uk-ar/09f901486c6ba138b451528bebf65dc7 to your computer and use it in GitHub Desktop.
> node
var Rx = require('rx');
var source = Rx.Observable.interval(500 /* ms */).timeInterval().take(3);
var source = Rx.Observable.from([1,2]);
var source = Rx.Observable.interval(1000).do(i=>console.log("s:",i)).map(
n=>{if(n === 2) {
throw 'ex';
}
return n;
}).retryWhen(function(errors) {
return errors.delay(200);
}).take(6).do(i=>console.log("e:",i))
var source = Rx.Observable.from([0,1,2,3,4,5]).do(i=>console.log("s:",i)).map(
n=>{if(n === 2) {
throw 'ex';
}
return n;
}).retryWhen(function(errors) {
return errors.delay(200);
}).take(6).do(i=>console.log("e:",i)).shareReplay()
var subscription = source.subscribe(function (x) {console.log('Next: ',x);},function (err) {console.log('Error: ' ,err);},function () {console.log('Completed');});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment