🌀
type-chef-di Docs
GitHub
  • 👋Welcome to type-chef-di documentation
  • Overview
    • ✨Getting started
  • Fundamentals
    • 🍎Container Options, extendability
    • 👨‍🍳Injection
      • 🍕Type injection
      • 🍪Token registration
      • ☕Token Injection
      • 🌮Mixed injection
    • 🛠️Decorators
      • ✅@Injectable({instantiation: "singleton" | "prototype"})
      • 🎯@Inject<T>(key: string | Type<T>)
      • 🍍@InjectProperty<T>(key: string | Type<T>)
      • 🍭@Setter()
      • 🔆@InitMethod()
      • 🏭@FactoryMethod()
      • ⚡@AddTags(tags)
      • 🪃@RunBefore(key: string | Type<IRunBefore>)
      • 🛴@RunAfter(key: string | Type<IRunAfter>)
      • 🌕@MethodWrapper(key: string | Type<IMethodWrapper>)
  • Use Cases
    • 🎨Plans
    • 🖥️For Developers
  • Other
    • 💡DI / IoC
Powered by GitBook
On this page
Edit on GitHub
  1. Fundamentals
  2. Decorators

@AddTags(tags)

Tag resolution:


@AddTags("tag1")
class Foo1 {
}

@AddTags(["tag2", "tagMultiple"])
class Foo2 {
}

@AddTags(["tag3", "tagMultiple"])
class Foo3 {
}

const container = new Container();
container.registerTypes([Foo1, Foo2, Foo3]);

const res1 = await container.resolveByTags("tagMultiple"); // return [ new Foo2(), new Foo3()]
const res2 = await container.resolveByTags("tagMultiple", "tag1"]); // return [new Foo1(), new Foo2(), new Foo3()]
  
Previous@FactoryMethod()Next@RunBefore(key: string | Type<IRunBefore>)

Last updated 2 years ago

🛠️
⚡