fix
This commit is contained in:
@@ -15,6 +15,8 @@ class DocumentsManager<T extends ManagedDocument = ManagedDocument> {
|
||||
|
||||
private listeners: Set<() => void>;
|
||||
|
||||
private emitScheduled: boolean;
|
||||
|
||||
constructor(
|
||||
fetchDocument?: FetchDocument,
|
||||
) {
|
||||
@@ -22,10 +24,18 @@ class DocumentsManager<T extends ManagedDocument = ManagedDocument> {
|
||||
this.fetcher = fetchDocument;
|
||||
this.inflight = new Map();
|
||||
this.listeners = new Set();
|
||||
this.emitScheduled = false;
|
||||
}
|
||||
|
||||
private emit() {
|
||||
this.listeners.forEach((fn) => fn());
|
||||
if (this.emitScheduled) {
|
||||
return;
|
||||
}
|
||||
this.emitScheduled = true;
|
||||
setTimeout(() => {
|
||||
this.emitScheduled = false;
|
||||
this.listeners.forEach((fn) => fn());
|
||||
}, 0);
|
||||
}
|
||||
|
||||
subscribe(listener: () => void) {
|
||||
|
||||
Reference in New Issue
Block a user