選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

Decorator.ts 619B

123456789101112131415161718192021
  1. import { Injector } from "./Injector";
  2. import { Type, GenericClassDecorator, Constructor } from "./Types";
  3. /**
  4. * @returns {GenericClassDecorator<Type<any>>}
  5. * @constructor
  6. */
  7. export function Singleton(_interface?: Constructor<any>): GenericClassDecorator<Type<any>> {
  8. return (clazz: Type<any>) => {
  9. Injector['modules'].push({
  10. implements: _interface ?? clazz,
  11. ctor: clazz
  12. })
  13. }
  14. }
  15. export function Inject(clazz: Constructor<any>) {
  16. return function (prototype: Object, key: string) {
  17. Injector['injectionQueue'].push({ injectionType: clazz, prototype: prototype, injectIntoKey: key })
  18. }
  19. }