@@ -1,7 +1,8 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { ReplaySubject } from 'rxjs';
|
||||
import { ReplaySubject, Observable } from 'rxjs';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { shareReplay } from 'rxjs/operators';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -9,24 +10,13 @@ import { environment } from 'src/environments/environment';
|
||||
export class AssetsService {
|
||||
network = environment.network;
|
||||
|
||||
assetsMinimal$ = new ReplaySubject<any>(1);
|
||||
getAssetsJson$: Observable<any>;
|
||||
getAssetsMinimalJson$: Observable<any>;
|
||||
|
||||
constructor(
|
||||
private httpClient: HttpClient,
|
||||
) {
|
||||
if (this.network === 'liquid') {
|
||||
this.getAssetsMinimalJson$();
|
||||
}
|
||||
}
|
||||
|
||||
getAssetsMinimalJson$() {
|
||||
this.httpClient.get('/resources/assets.minimal.json')
|
||||
.subscribe((data) => {
|
||||
this.assetsMinimal$.next(data);
|
||||
});
|
||||
}
|
||||
|
||||
getAssetsJson$() {
|
||||
return this.httpClient.get('/resources/assets.json');
|
||||
this.getAssetsJson$ = this.httpClient.get('/resources/assets.json').pipe(shareReplay());
|
||||
this.getAssetsMinimalJson$ = this.httpClient.get('/resources/assets.minimal.json').pipe(shareReplay());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ export class StateService {
|
||||
mempoolBlocks$ = new ReplaySubject<MempoolBlock[]>(1);
|
||||
txConfirmed$ = new Subject<Block>();
|
||||
mempoolTransactions$ = new Subject<Transaction>();
|
||||
assetTransactions$ = new Subject<Transaction>();
|
||||
blockTransactions$ = new Subject<Transaction>();
|
||||
|
||||
live2Chart$ = new Subject<OptimizedMempoolStats>();
|
||||
|
||||
@@ -96,6 +96,18 @@ export class WebsocketService {
|
||||
});
|
||||
}
|
||||
|
||||
if (response['asset-transactions']) {
|
||||
response['asset-transactions'].forEach((assetTransaction: Transaction) => {
|
||||
this.stateService.assetTransactions$.next(assetTransaction);
|
||||
});
|
||||
}
|
||||
|
||||
if (response['asset-block-transactions']) {
|
||||
response['asset-block-transactions'].forEach((addressTransaction: Transaction) => {
|
||||
this.stateService.blockTransactions$.next(addressTransaction);
|
||||
});
|
||||
}
|
||||
|
||||
if (response['live-2h-chart']) {
|
||||
this.stateService.live2Chart$.next(response['live-2h-chart']);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user