clean up observers

This commit is contained in:
David Tsay 2022-03-16 10:27:01 -07:00
parent 50997270e9
commit c14cc25977

View File

@ -69,13 +69,8 @@ class InMemorySearchProvider {
this.worker.port.close();
}
Object.entries(this.indexedIds).forEach(([keyString, unobserve]) => {
if (typeof unobserve === 'function') {
unobserve();
}
delete this.indexedIds[keyString];
});
this.destroyObservers(this.indexedIds);
this.destroyObservers(this.indexedCompositions);
});
}
@ -375,6 +370,16 @@ class InMemorySearchProvider {
};
this.onWorkerMessage(eventToReturn);
}
destroyObservers(observers) {
Object.entries(observers).forEach(([keyString, unobserve]) => {
if (typeof unobserve === 'function') {
unobserve();
}
delete observers[keyString];
});
}
}
export default InMemorySearchProvider;