UNPKG

rage-framework

Version:

## How to Install *server-side* ```bash npm install @rage-framework/server ```

65 lines 2.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Container = void 0; const ContainerInstance_1 = require("./ContainerInstance"); class Container { // ------------------------------------------------------------------------- // Public Static Methods // ------------------------------------------------------------------------- static of(instanceId) { if (instanceId === undefined) return this.globalInstance; let container = this.instances.get(instanceId); if (!container) { container = new ContainerInstance_1.ContainerInstance(instanceId); this.instances.set(instanceId, container); } return container; } static has(identifier) { return this.globalInstance.has(identifier); } static get(identifier) { return this.globalInstance.get(identifier); } static getMany(id) { return this.globalInstance.getMany(id); } static set(identifierOrServiceMetadata, value) { this.globalInstance.set(identifierOrServiceMetadata, value); return this; } static remove(...ids) { this.globalInstance.remove(...ids); return this; } static reset(containerId) { if (containerId) { const instance = this.instances.get(containerId); if (instance) { instance.reset(); this.instances.delete(containerId); } } else { this.globalInstance.reset(); Array.from(this.instances.values()).forEach(i => i.reset()); } return this; } static registerHandler(handler) { this.handlers.set(handler, handler); return this; } static import(services) { return this; } } exports.Container = Container; // ------------------------------------------------------------------------- // Private Static Properties // ------------------------------------------------------------------------- Container.globalInstance = new ContainerInstance_1.ContainerInstance(undefined); Container.instances = new Map(); Container.handlers = new Map(); //# sourceMappingURL=Container.js.map