Skip to content

Instantly share code, notes, and snippets.

@amit777
Created January 6, 2018 04:03
Show Gist options
  • Save amit777/203950ad016f0cf577f311eb9307501e to your computer and use it in GitHub Desktop.
Save amit777/203950ad016f0cf577f311eb9307501e to your computer and use it in GitHub Desktop.
RxJS Observer outside of Observable.create
var Rx = require('rxjs');
var source;
var timeline = Rx.Observable.create(function(observer){
var to;
var last = null;
source = observer;
return function() {
console.log('observer ended ');
};
});
setTimeout(function(){
source.next('First data');
setTimeout(function(){
source.next('Second data');
source.complete();
}, 500);
}, 100);
timeline.subscribe(function(d){
console.log('subscribe '+d);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment