Let's say I have a component named FooComponent and in the html template there is an element using an async pipe [data]="messageService.messages | async".
In MessageService, the property messages is a BehaviorSubject:
private _messages = new BehaviorSubject(this._loadedMessages[this.environmentId]);
get messages(): BehaviorSubject<Message[]> { return this._messages; }
In FooComponent I can open a mdDialog and in this dialog a function of MessageService is called which is changing the value of the subject behavior:
this._messages.next(this._loadedMessages[this.environmentId]);
The problem is, after closing the dialog, in the function Subject.prototype.next(value) of SubjectBehavior,FooComponent is not an observer anymore.
I know that aync pipe prevent memory leaks by unsubscribing on component destruction, but opening a dialog does'nt destroy FooComponent...
Why I am losing the observer reference?