Merge pull request #4933 from mempool/natsoni/fix-address-component-subscriptions
Fix subscription management in address component
This commit is contained in:
commit
192fd09a00
@ -28,6 +28,9 @@ export class AddressComponent implements OnInit, OnDestroy {
|
|||||||
retryLoadMore = false;
|
retryLoadMore = false;
|
||||||
error: any;
|
error: any;
|
||||||
mainSubscription: Subscription;
|
mainSubscription: Subscription;
|
||||||
|
mempoolTxSubscription: Subscription;
|
||||||
|
mempoolRemovedTxSubscription: Subscription;
|
||||||
|
blockTxSubscription: Subscription;
|
||||||
addressLoadingStatus$: Observable<number>;
|
addressLoadingStatus$: Observable<number>;
|
||||||
addressInfo: null | AddressInformation = null;
|
addressInfo: null | AddressInformation = null;
|
||||||
|
|
||||||
@ -179,17 +182,17 @@ export class AddressComponent implements OnInit, OnDestroy {
|
|||||||
this.isLoadingAddress = false;
|
this.isLoadingAddress = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.stateService.mempoolTransactions$
|
this.mempoolTxSubscription = this.stateService.mempoolTransactions$
|
||||||
.subscribe(tx => {
|
.subscribe(tx => {
|
||||||
this.addTransaction(tx);
|
this.addTransaction(tx);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.stateService.mempoolRemovedTransactions$
|
this.mempoolRemovedTxSubscription = this.stateService.mempoolRemovedTransactions$
|
||||||
.subscribe(tx => {
|
.subscribe(tx => {
|
||||||
this.removeTransaction(tx);
|
this.removeTransaction(tx);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.stateService.blockTransactions$
|
this.blockTxSubscription = this.stateService.blockTransactions$
|
||||||
.subscribe((transaction) => {
|
.subscribe((transaction) => {
|
||||||
const tx = this.transactions.find((t) => t.txid === transaction.txid);
|
const tx = this.transactions.find((t) => t.txid === transaction.txid);
|
||||||
if (tx) {
|
if (tx) {
|
||||||
@ -295,6 +298,9 @@ export class AddressComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this.mainSubscription.unsubscribe();
|
this.mainSubscription.unsubscribe();
|
||||||
|
this.mempoolTxSubscription.unsubscribe();
|
||||||
|
this.mempoolRemovedTxSubscription.unsubscribe();
|
||||||
|
this.blockTxSubscription.unsubscribe();
|
||||||
this.websocketService.stopTrackingAddress();
|
this.websocketService.stopTrackingAddress();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user