Adding a global websocket loader observable.

fixes #95
This commit is contained in:
softsimon
2020-07-22 19:21:40 +07:00
parent 6b3e84255a
commit 0f611ecf8a
5 changed files with 15 additions and 7 deletions

View File

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