UNPKG

react-obsidian

Version:

Dependency injection framework for React and React Native applications

24 lines 834 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const useGraph_1 = __importDefault(require("../components/useGraph")); class HookInjector { inject(hook, Graph) { return (args) => { const graph = (0, useGraph_1.default)(Graph, hook, args); return hook(new Proxy(args !== null && args !== void 0 ? args : {}, new Injector(graph))); }; } } exports.default = HookInjector; class Injector { constructor(graph) { this.graph = graph; } get(obj, property, receiver) { return property in obj ? obj[property] : this.graph.retrieve(property, receiver); } } //# sourceMappingURL=HookInjector.js.map