123456789101112131415161718192021 |
- import { Injector } from "./Injector";
- import { Type, GenericClassDecorator, Constructor } from "./Types";
-
- /**
- * @returns {GenericClassDecorator<Type<any>>}
- * @constructor
- */
- export function Singleton(_interface?: Constructor<any>): GenericClassDecorator<Type<any>> {
- return (clazz: Type<any>) => {
- Injector['modules'].push({
- implements: _interface ?? clazz,
- ctor: clazz
- })
- }
- }
-
- export function Inject(clazz: Constructor<any>) {
- return function (instance: Object, key: string) {
- Injector['injectionQueue'].push({ injectionType: clazz, instance: instance, injectIntoKey: key })
- }
- }
|