I am trying to clear an observable that contains data which will be shown in a table. Currently I have an input$
observable that combines the latest data like so:
this.inputs$ = observableCombineLatest(
this.paymentDates$,
...
this.reassessmentDate$,
(
paymentDates,
...
reassessmentDate,
) => ({
paymentDates,
...
reassessmentDate,
}),
).pipe(debounceTime(500));
Once each value has been recieved it will trigger another observable setting the data it needs for the table:
this.transactionSummary$ = this.inputs$
.pipe(
map(this.mapDataForTransactionSummary, this),
share(),
)
.pipe(
mergeMap(data => {
debugger;
return this.taxService.getTransactionSummary(data);
}),
)
.pipe(
tap(this.transactionSummaryEmitter),
map(this.calculateComputedValues),
share(),
);
The html that determines displaying it is as follows:
<div *ngIf="(transactionSummary$ | async) as summaryData; else loading">
Now when the table first loads it works fine no problem but If i say select a new user in this case and reload the table it will contain the data form the previous user and will after a couple of seconds update with the new data, however I dont want to show the old data and would rather it not show while the new data comes through.
So my solution to this was simply adding a tap to the inputs$
observable and set the transactionSummary$
to null,
.pipe(tap(() => {
this.transactionSummary$ = null;
}), debounceTime(500));
however this doesnt work at all, just doesn't load the table. Any ideas why that might be?