| 12345678910111213141516171819202122232425262728293031323334353637 |
- import { Injector } from "./Injector";
- import { Type, GenericClassDecorator } from "./Util";
- import { FrontworkComponent } from "../Types/FrontworkComponent";
-
- /**
- * @returns {GenericClassDecorator<Type<any>>}
- * @constructor
- */
- export const Injectable = (_interface?: Type<any>) : GenericClassDecorator<Type<any>> => {
- return (target: Type<any>) => {
- Injector.modules.push({
- implements: _interface,
- implementation: target
- })
- }
- }
-
- /**
- * @returns {GenericClassDecorator<Type<any>>}
- * @constructor
- */
- export const RootComponent = (config : {
- injectable : Type<any>
- injects : Type<FrontworkComponent>[]
- }) : GenericClassDecorator<Type<any>> => {
- return (target: Type<any>) => {
- Injector.rootModules = config.injects
- Injector.rootInterface = config.injectable
- Injector.root = target
- }
- }
-
- export const Inject = (type: any) => {
- return function (_this, key) {
- Injector.injectionQueue.push({what: type, target: _this, where:key})
- }
- }
|