From c537a07ea937e69b66841d903c70fd75623e5457 Mon Sep 17 00:00:00 2001 From: Alex Inkin Date: Sat, 22 Jun 2024 11:26:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20move=20cache=20to=20optional=20construc?= =?UTF-8?q?tor=20argument,=20so=20it=20can=20be=20exter=E2=80=A6=20(#64)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: move cache to optional constructor argument, so it can be externalized Signed-off-by: waterplea * chore: make cache private Signed-off-by: waterplea --------- Signed-off-by: waterplea --- client/lib/patch-db.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/client/lib/patch-db.ts b/client/lib/patch-db.ts index cb428ac..0587c84 100644 --- a/client/lib/patch-db.ts +++ b/client/lib/patch-db.ts @@ -24,12 +24,13 @@ export class PatchDB { } } = {} - readonly cache$ = new BehaviorSubject>({ - id: 0, - value: {} as T, - }) - - constructor(private readonly source$: Observable[]>) {} + constructor( + private readonly source$: Observable[]>, + private readonly cache$ = new BehaviorSubject>({ + id: 0, + value: {} as T, + }), + ) {} start() { if (this.sub) return