dependencyWithNew.js 715 B

1234567891011121314151617181920
  1. import { getDependencyByIndex } from './decorators';
  2. function changeToSelf(target, index, withNew) {
  3. var descriptor = getDependencyByIndex(target, index);
  4. descriptor.withNew = withNew;
  5. }
  6. function withNewDecoratorFactoryProducer(withNew) {
  7. return function DecoratorFactory() {
  8. if (this instanceof DecoratorFactory) {
  9. return this;
  10. }
  11. return function (target, _key, index) {
  12. changeToSelf(target, index, withNew);
  13. };
  14. };
  15. }
  16. /**
  17. * Always initialize a new instance of that dependency instead of getting the cached instance from the injector.
  18. */
  19. export var WithNew = withNewDecoratorFactoryProducer(true);
  20. //# sourceMappingURL=dependencyWithNew.js.map