skip injecting an instance if it's already injected

This commit is contained in:
Mads Rasmussen
2022-05-19 16:45:45 +02:00
parent 9c50a70415
commit ff352569bd

View File

@@ -15,11 +15,12 @@ export function UmbContextInjectMixin<TBase extends Constructor>(Base: TBase) {
* @param {string} contextKey
*/
requestContext(contextKey: string) {
if (this._requesters.has(contextKey)) {
return;
}
if (this._requesters.has(contextKey)) return;
const requester = new UmbContextRequester(this, contextKey, (_instance: any) => {
// don't to anything if the context is already resolved
if (this._resolved.has(contextKey) && this._resolved.get(contextKey) === _instance) return;
this._resolved.set(contextKey, _instance);
this.contextInjected(this._resolved);
});