I have a class Message, that contains an array of Addresses. Opening the page immediately querys all the pending messages. I need the Adresses to be queryed once the user opens the tab inside the message. The problem is that the Addresses and Messages are handled as 2 different objects instead of as one whole
getMessages(): void {
let request: GetPendingMessagesRequest;
this.isLoadingResultSubject.next(true);
this.messagesQuery$.next();
this.messagesQuery$.complete();
this.messagesQuery$ = new Subject();
this.queryDispatcher.dispatch(request, null, this.messagesQuery$)
.pipe(takeUntil(this.destroy$))
.subscribe({
next: (getResponse: GetPendingMessagesResponse) => {
this.messagesSubject.next(getResponse.messages);
this.isLoadingResultSubject.next(false);
},
error: () => this.MessagesService.delete()
});
}
getAddresses(ObjektId: string | number, documentId: string | number, document: Document): void {
let request: GetAddressesRequest;
request = new GetAddressesRequest(
ObjektId,
documentId,
);
this.addressesQuery$.next();
this.addressesQuery$ = new Subject();
this.queryDispatcher.dispatch(request, null, this.addressesQuery$)
.pipe(takeUntil(this.destroy$))
.subscribe({next:(getaddressesResponse: GetAddressesResponse) => {
this.addressesSubject.next(getaddressesResponse.addresses)
}, error: () => this.AdressesService.delete()});
}
Currently i've had 3 different results.
- All the information is correct but gets queryed as soon as the first Message tab is opened.
- Information is only correct on the last message queyed and displayed data gets changed for all the rest to match the last query.
- Everything works correctly except there is a button on each message to query its Addresses.