feat: move cache to optional constructor argument, so it can be exter… (#64)

* feat: move cache to optional constructor argument, so it can be externalized

Signed-off-by: waterplea <alexander@inkin.ru>

* chore: make cache private

Signed-off-by: waterplea <alexander@inkin.ru>

---------

Signed-off-by: waterplea <alexander@inkin.ru>
This commit is contained in:
Alex Inkin
2024-06-22 11:26:18 +08:00
committed by GitHub
parent 7aa53249f9
commit c537a07ea9

View File

@@ -24,12 +24,13 @@ export class PatchDB<T extends { [key: string]: any }> {
}
} = {}
readonly cache$ = new BehaviorSubject<Dump<T>>({
constructor(
private readonly source$: Observable<Update<T>[]>,
private readonly cache$ = new BehaviorSubject<Dump<T>>({
id: 0,
value: {} as T,
})
constructor(private readonly source$: Observable<Update<T>[]>) {}
}),
) {}
start() {
if (this.sub) return