From 3972b76d10a9e47cddf3187a62c07feb8607efc9 Mon Sep 17 00:00:00 2001 From: waterplea Date: Tue, 17 May 2022 11:21:33 +0300 Subject: [PATCH] chore: send the most recent cache upon subscription --- client/lib/patch-db.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/lib/patch-db.ts b/client/lib/patch-db.ts index 9da3c4c..501db48 100644 --- a/client/lib/patch-db.ts +++ b/client/lib/patch-db.ts @@ -1,4 +1,4 @@ -import { merge, Observable, Subject, Subscription } from 'rxjs' +import { merge, Observable, ReplaySubject, Subject, Subscription } from 'rxjs' import { Store } from './store' import { DBCache, Http } from './types' import { RPCError } from './source/ws-source' @@ -8,7 +8,7 @@ export class PatchDB { public store: Store = new Store(this.http, this.initialCache) public connectionError$ = new Subject() public rpcError$ = new Subject() - public cache$ = new Subject>() + public cache$ = new ReplaySubject>(1) private updatesSub?: Subscription private sourcesSub = this.sources$.subscribe(sources => {