mirror of
https://github.com/Start9Labs/patch-db.git
synced 2026-03-31 04:13:39 +00:00
chore: send the most recent cache upon subscription
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { merge, Observable, Subject, Subscription } from 'rxjs'
|
import { merge, Observable, ReplaySubject, Subject, Subscription } from 'rxjs'
|
||||||
import { Store } from './store'
|
import { Store } from './store'
|
||||||
import { DBCache, Http } from './types'
|
import { DBCache, Http } from './types'
|
||||||
import { RPCError } from './source/ws-source'
|
import { RPCError } from './source/ws-source'
|
||||||
@@ -8,7 +8,7 @@ export class PatchDB<T> {
|
|||||||
public store: Store<T> = new Store(this.http, this.initialCache)
|
public store: Store<T> = new Store(this.http, this.initialCache)
|
||||||
public connectionError$ = new Subject<Error>()
|
public connectionError$ = new Subject<Error>()
|
||||||
public rpcError$ = new Subject<RPCError>()
|
public rpcError$ = new Subject<RPCError>()
|
||||||
public cache$ = new Subject<DBCache<T>>()
|
public cache$ = new ReplaySubject<DBCache<T>>(1)
|
||||||
|
|
||||||
private updatesSub?: Subscription
|
private updatesSub?: Subscription
|
||||||
private sourcesSub = this.sources$.subscribe(sources => {
|
private sourcesSub = this.sources$.subscribe(sources => {
|
||||||
|
|||||||
Reference in New Issue
Block a user