I have a MessageService component for the interaction between components wherever they are in the app, they just use the subscribe and sendMessage methods of injected MessageService.
When I load a page with A, B component messages can be exchanged, but as use another independent observable function (http.get of HttpClient request to load data) the MessageService subject subscribers decrease from 2 to 1. And A and B cant exchange messages.
My question is, how can I find out what's happening in the background?
UPDATED - BELOW
When the page load then no problem but after loading some data from the net. In A message fired but it doesnt arrive at B
A. (its container has injected MessageService, and accessed by "this")
<file-export [fileExportInput]="this" *ngIf="hasExport"></file-export>
@Input()
fileExportInput: FileExportInputInterface;
ngOnInit() {
console.log("fileexport message service:", this.fileExportInput.messageService);
this.fileExportInput.messageService ? this.message = true : this.message = false;
if (this.message) {
this.message$ = {
next: (message: Message) => {
....
this.$subscription = this.fileExportInput.messageService.subscribe(this.message$);
}
}
B
constructor(private router: Router, private boeManagementService: BoeManagementService,
private translateService: TranslateService, public messageService: MessageService) {
console.log("boex message service:", this.messageService);
/** file-export */
this.message$ = {
next: (message: Message) => {
if (message.type === MessageType.FILE_EXPORT_ELEMENTS_REQUEST) { <---- CANT be reached this part
....
this.$subscription = this.messageService.subscribe(this.message$);
}
Thanks in advance,
Csaba