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 { DBCache, HashMap, Http } from './types'
|
||||
|
||||
export class PatchDB<T> {
|
||||
export class PatchDB<T extends HashMap> {
|
||||
store: Store<T>
|
||||
|
||||
constructor (
|
||||
@@ -15,7 +15,7 @@ export class PatchDB<T> {
|
||||
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)))
|
||||
.pipe(
|
||||
tap(update => this.store.update(update)),
|
||||
|
||||
@@ -8,8 +8,8 @@ export interface StashEntry {
|
||||
undo: Operation[]
|
||||
}
|
||||
|
||||
export class Store<T> {
|
||||
cache: DBCache<HashMap>
|
||||
export class Store<T extends HashMap> {
|
||||
cache: DBCache<T>
|
||||
sequence$: BehaviorSubject<number>
|
||||
private watchedNodes: { [path: string]: BehaviorSubject<any> } = { }
|
||||
private stash = new BTree<number, StashEntry>()
|
||||
|
||||
Reference in New Issue
Block a user