Skip to content

Commit

Permalink
chore: one server request
Browse files Browse the repository at this point in the history
  • Loading branch information
MishaZhem committed Aug 22, 2024
1 parent 4b62c2f commit 693e0c4
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export interface TableData {
})
export class PoolsComponent {
protected cryptoService = inject(CryptoService);
protected tokens = toSignal(this.cryptoService.getTokens());
protected tokens = toSignal(this.cryptoService.tokens);
protected tableData: Signal<TableData[]> = computed(() => {
const tokens = this.tokens() || [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {CryptoService} from '../../../../../services/crypto.service';
})
export class PriceListComponent {
protected pricesService = inject(CryptoService);
protected tokens$ = this.pricesService.getTokens();
protected tokens$ = this.pricesService.tokens;

protected showTokens = 4;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import {CoinIconPipe} from '../../pipes/coin-icon.pipe';
export class StakingComponent {
private readonly dialogs = inject(TuiDialogService);
private readonly cryptoService = inject(CryptoService);
protected tokens = toSignal(this.cryptoService.getTokens());
protected tokens = toSignal(this.cryptoService.tokens);
protected price = computed(
() =>
this.amount() *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import {CryptoService} from '../../../../services/crypto.service';
})
export class SwapComponent {
protected readonly cryptoService = inject(CryptoService);
protected readonly tokens = toSignal(this.cryptoService.getTokens());
protected readonly tokens = toSignal(this.cryptoService.tokens);
protected readonly priceFrom = computed(() => this.getPrice(this.tokenFrom()));

protected readonly priceTo = computed(() => this.getPrice(this.tokenTo()));
Expand Down
5 changes: 3 additions & 2 deletions apps/taiga-lumbermill/src/services/crypto.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ export class CryptoService {
private readonly http = inject(HttpClient);

private readonly API = inject(CryptoApi);
public readonly tokens = this.getTokens();

public getTokens(): Observable<PricesData[]> {
return this.http
.get<ResponseData>(this.API)
.pipe(shareReplay({bufferSize: 1, refCount: false}))
.pipe(map((info) => info.data));
.pipe(map((info) => info.data))
.pipe(shareReplay({bufferSize: 10, refCount: true}));
}

public getHistory(id: string, interval: string): Observable<HistoryData[]> {
Expand Down

0 comments on commit 693e0c4

Please sign in to comment.