extends hashmap

This commit is contained in:
Drew Ansbacher
2021-07-21 14:47:38 -06:00
committed by Aiden McClelland
parent 88084f60a2
commit cf43a9a83e
2 changed files with 4 additions and 4 deletions

View File

@@ -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)),

View File

@@ -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>()