rxjs#shareReplay TypeScript Examples

The following examples show how to use rxjs#shareReplay. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PoolInfoTask.ts    From guardian with Apache License 2.0 5 votes vote down vote up
getPoolState = (apiRx: ApiRx, poolId: LiquidityPoolId, period: number) => {
  const stream$ = timer(0, period).pipe(
    switchMap(() => apiRx.rpc.margin.poolState(poolId)),
    distinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b)),
    shareReplay({ refCount: true, bufferSize: 1 })
  );
  return stream$;
}