Suppose I have an Observable that has been created like this
let observable = of(mockData).pipe(delay(5000));
How can I at an later point in time, emit another value to the observers currently subscribing to this observable?
I have read this RxJS: How would I "manually" update an Observable? and BehaviorSubject vs Observable? but I can not seems to grasps why I am holding an object of type Observable in my hand, and can not access any easy way to emit data to observers without defining an emitter independently at the observable creation time like this
var emitter;
var observable = Rx.Observable.create(e => emitter = e);
var observer = {
next: function(next) {
console.log(next);
},
error: function(error) {
console.log(error);
},
complete: function() {
console.log("done");
}
}
observable.subscribe(observer);
emitter.next('foo');
emitter.next('bar');
emitter.next('baz');
emitter.complete();
//console output
//"foo"
//"bar"
//"baz"
//"done"