vulcain-corejs
Version:
Vulcain micro-service framework
29 lines (27 loc) • 805 B
JavaScript
class Scope {
constructor(parent, requestContext) {
this.parent = parent;
this.requestContext = requestContext;
this.cache = new Map();
}
getInstance(name) {
if (!name)
throw new Error("name argument must not be null");
let component = this.cache.get(name);
return component || this.parent && this.parent.getInstance(name);
}
set(name, component) {
if (!name)
throw new Error("name argument must not be null");
this.cache.set(name, component);
}
dispose() {
this.cache.forEach(v => v.dispose && v.dispose());
this.cache.clear();
this.parent = null;
this.requestContext = null;
}
}
exports.Scope = Scope;
//# sourceMappingURL=scope.js.map
;