Subscription refactoring to increase performance.

This commit is contained in:
softsimon
2020-07-30 17:01:13 +07:00
parent bb6272469d
commit 58a6bbd88b
8 changed files with 89 additions and 60 deletions

View File

@@ -1,28 +1,21 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Component, OnInit, OnDestroy, ChangeDetectionStrategy } from '@angular/core';
import { StateService } from 'src/app/services/state.service';
import { Subscription } from 'rxjs';
import { Subscription, Observable } from 'rxjs';
@Component({
selector: 'app-blockchain',
templateUrl: './blockchain.component.html',
styleUrls: ['./blockchain.component.scss']
styleUrls: ['./blockchain.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class BlockchainComponent implements OnInit, OnDestroy {
txTrackingLoading = false;
txShowTxNotFound = false;
isLoading = true;
subscription: Subscription;
export class BlockchainComponent implements OnInit {
isLoading$: Observable<boolean>;
constructor(
private stateService: StateService,
) {}
ngOnInit() {
this.subscription = this.stateService.isLoadingWebSocket$
.subscribe((isLoading) => this.isLoading = isLoading);
}
ngOnDestroy() {
this.subscription.unsubscribe();
this.isLoading$ = this.stateService.isLoadingWebSocket$;
}
}