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

@@ -29,6 +29,7 @@ export class StateService {
txReplaced$ = new Subject<Transaction>();
mempoolTransactions$ = new Subject<Transaction>();
blockTransactions$ = new Subject<Transaction>();
isLoadingWebSocket$ = new ReplaySubject<boolean>(1);
live2Chart$ = new Subject<OptimizedMempoolStats>();

View File

@@ -52,16 +52,17 @@ export class WebsocketService {
this.startSubscription();
});
}
startSubscription(retrying = false) {
this.stateService.isLoadingWebSocket$.next(true);
if (retrying) {
this.stateService.connectionState$.next(1);
}
this.websocketSubject.next({'action': 'init'});
this.subscription = this.websocketSubject
.subscribe((response: WebsocketResponse) => {
this.stateService.isLoadingWebSocket$.next(false);
if (response.blocks && response.blocks.length) {
const blocks = response.blocks;
blocks.forEach((block: Block) => {