react-obsidian
Version:
Dependency injection framework for React and React Native applications
23 lines • 1.05 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.injectComponent = void 0;
const isString_1 = require("../../utils/isString");
const ComponentInjector_1 = __importDefault(require("./ComponentInjector"));
const componentInjector = new ComponentInjector_1.default();
const injectComponent = (Target, keyOrGraph) => {
assertGraph(keyOrGraph, Target);
return componentInjector.inject(Target, keyOrGraph);
};
exports.injectComponent = injectComponent;
function assertGraph(keyOrGraph, Target) {
if (!(0, isString_1.isString)(keyOrGraph) && !keyOrGraph) {
throw new Error(`injectComponent was called with an undefined Graph.`
+ `This is probably not an issue with Obsidian.`
+ `It's typically caused by circular dependencies.`
+ ` Check the implementation of ${Target.name}.`);
}
}
//# sourceMappingURL=InjectComponent.js.map