Skip to content

Commit

Permalink
chore: add shareReplay
Browse files Browse the repository at this point in the history
  • Loading branch information
MishaZhem committed Aug 22, 2024
1 parent 16794a4 commit 4b62c2f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions apps/taiga-lumbermill/src/services/crypto.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {HttpClient} from '@angular/common/http';
import {inject, Injectable, InjectionToken} from '@angular/core';
import {map, type Observable} from 'rxjs';
import {map, type Observable, shareReplay} from 'rxjs';

export interface PricesData {
readonly id: string;
Expand Down Expand Up @@ -38,7 +38,10 @@ export class CryptoService {
private readonly API = inject(CryptoApi);

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

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

0 comments on commit 4b62c2f

Please sign in to comment.