mirror of
https://github.com/Start9Labs/patch-db.git
synced 2026-03-26 10:21:53 +00:00
extends hashmap
This commit is contained in:
committed by
Matt Hill
parent
37ad3091bd
commit
7f7f7b6503
@@ -4,7 +4,7 @@ import { Source } from './source/source'
|
|||||||
import { Store } from './store'
|
import { Store } from './store'
|
||||||
import { DBCache, HashMap, Http } from './types'
|
import { DBCache, HashMap, Http } from './types'
|
||||||
|
|
||||||
export class PatchDB<T> {
|
export class PatchDB<T extends HashMap> {
|
||||||
store: Store<T>
|
store: Store<T>
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
@@ -15,7 +15,7 @@ export class PatchDB<T> {
|
|||||||
this.store = new Store(this.http, this.initialCache)
|
this.store = new Store(this.http, this.initialCache)
|
||||||
}
|
}
|
||||||
|
|
||||||
sync$ (): Observable<DBCache<HashMap>> {
|
sync$ (): Observable<DBCache<T>> {
|
||||||
return merge(...this.sources.map(s => s.watch$(this.store)))
|
return merge(...this.sources.map(s => s.watch$(this.store)))
|
||||||
.pipe(
|
.pipe(
|
||||||
tap(update => this.store.update(update)),
|
tap(update => this.store.update(update)),
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ export interface StashEntry {
|
|||||||
undo: Operation[]
|
undo: Operation[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Store<T> {
|
export class Store<T extends HashMap> {
|
||||||
cache: DBCache<HashMap>
|
cache: DBCache<T>
|
||||||
sequence$: BehaviorSubject<number>
|
sequence$: BehaviorSubject<number>
|
||||||
private watchedNodes: { [path: string]: BehaviorSubject<any> } = { }
|
private watchedNodes: { [path: string]: BehaviorSubject<any> } = { }
|
||||||
private stash = new BTree<number, StashEntry>()
|
private stash = new BTree<number, StashEntry>()
|
||||||
|
|||||||
Reference in New Issue
Block a user