UNPKG

react-obsidian

Version:

Dependency injection framework for React and React Native applications

40 lines 1.79 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const ConstructorArgs_1 = require("./ConstructorArgs"); class InjectionMetadata { constructor() { this.injectionMetadataKey = 'injectionMetadata'; this.injectedConstructorArgsKey = 'injectedConstructorArgsKey'; this.lateInjectionMetadataKey = 'lateInjectionMetadataKey'; } getConstructorArgsToInject(target) { var _a; return (_a = Reflect.getMetadata(this.injectedConstructorArgsKey, target)) !== null && _a !== void 0 ? _a : new ConstructorArgs_1.ConstructorArgs(); } getPropertiesToInject(target) { return this.getProperties(this.injectionMetadataKey, target); } getLatePropertiesToInject(target) { return this.getProperties(this.lateInjectionMetadataKey, target); } saveConstructorParamMetadata(target, paramName, index) { const argsToInject = this.getConstructorArgsToInject(target); argsToInject.add(paramName, index); Reflect.defineMetadata(this.injectedConstructorArgsKey, argsToInject, target); } savePropertyMetadata(target, property) { this.saveProperties(this.injectionMetadataKey, this.getPropertiesToInject(target).add(property), target); } saveLatePropertyMetadata(target, property) { this.saveProperties(this.lateInjectionMetadataKey, this.getLatePropertiesToInject(target).add(property), target); } saveProperties(key, properties, target) { Reflect.defineMetadata(key, properties, target); } getProperties(key, target) { var _a; return (_a = Reflect.getMetadata(key, target)) !== null && _a !== void 0 ? _a : new Set(); } } exports.default = InjectionMetadata; //# sourceMappingURL=InjectionMetadata.js.map