2020-11-25 08:51:15 +01:00
|
|
|
import { Injectable } from '@angular/core';
|
2020-12-05 07:29:18 +01:00
|
|
|
import {HttpClient} from '@angular/common/http';
|
2021-02-17 13:49:04 +01:00
|
|
|
import {environment} from '@src/environments/environment';
|
2020-12-05 07:29:18 +01:00
|
|
|
import {first} from 'rxjs/operators';
|
|
|
|
import {BehaviorSubject} from 'rxjs';
|
2020-11-25 08:51:15 +01:00
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
providedIn: 'root'
|
|
|
|
})
|
|
|
|
export class TokenService {
|
2020-12-05 07:29:18 +01:00
|
|
|
tokens: any = '';
|
|
|
|
private tokensList = new BehaviorSubject<any>(this.tokens);
|
|
|
|
tokensSubject = this.tokensList.asObservable();
|
2020-11-25 08:51:15 +01:00
|
|
|
|
2020-12-05 07:29:18 +01:00
|
|
|
constructor(
|
|
|
|
private http: HttpClient
|
|
|
|
) { }
|
2020-11-25 08:51:15 +01:00
|
|
|
|
2020-12-05 07:29:18 +01:00
|
|
|
getTokens(): any {
|
|
|
|
this.http.get(`${environment.cicCacheUrl}/tokens`).pipe(first()).subscribe(tokens => this.tokensList.next(tokens));
|
|
|
|
}
|
|
|
|
|
|
|
|
getTokenBySymbol(symbol: string): any {
|
|
|
|
return this.http.get(`${environment.cicCacheUrl}/tokens/${symbol}`);
|
2020-11-25 08:51:15 +01:00
|
|
|
}
|
|
|
|
}
|