It's more of a theoretical question, since I don't have the code at hand, but I think it can be anwsered nevertheless.
I have a service (MsgService) that is responsible for supplying msg-s to components. When I update/set msg-s of the service from one of the components with a method similar to this one:
myMethod(data) {
this.myMethodSubject.next(data);
}
the new msg-s are not visible rigth away, but only after I refresh the page. I'd like to see the results of calling next
immidiately on all the components (that are subscribed to it) and views, but I need to refresh the page once to make the results visible. What can be the reason for that? Or to put it more generally - under what circumstances are the results of Next
and subscribtion visible rigth away?
(BTW:I'm calling the subscribe method that gives me the msg-s from NgOnInit, should I put it somewhere else?)
Edit: my subscription from one of the components looks something like this:
ngOnInit() { this.msgService.getMsgParams().subscribe(data => { this.params = data; });
this.msgService.getMsgs (this.params.category, this.params.price, this.params.title).subscribe(data => this.msgs = data);
}
So far, I haven't yet unsubscribed, is that connected with the issue?