You subscribe to your watched twice. The Async channel does this inside your subscription.
When the subscribe
method is executed , it executes the subscribe
function
observer => this.observer = observer
and overrides the property this.observer
so it will only act for the async pipe (last caller)
I would use an operator share
to solve it
new Observable(observer => this.observer = observer).share();
Plunger example
To see why is being this.observer
overridden, just run this code
let myObserver;
const observable$ = new Rx.Observable(function subscribe(observer) {
console.log('subscribe function has been called');
myObserver = observer;
});
observable$.subscribe(function next1() { console.log('next1'); });
observable$.subscribe(function next2() { console.log('next2'); });
observable$.subscribe(function next3() { console.log('next3'); });
myObserver.next();
jsbin.com
As I said, early async pipe subscribes internally observable
https://github.com/angular/angular/blob/4.3.x/packages/common/src/pipes/async_pipe.ts#L23
source
to share