Skip to content

annotation Athena::DependencyInjection::TaggedIterator #

Can be applied to a collection parameter to provide all the services with a specific tag. Supported collection types include: Indexable, Enumerable, and Iterator. Accepts an optional tag name as the first positional parameter, otherwise defaults to the FQN of the type within the collection type's generic.


This type is best used in conjunction with ADI::AutoconfigureTag.

The provided type lazily initializes the provided services as they are accessed.


class Foo
  # Inject all services tagged with `"some-tag"`.
  def initialize(@[ADI::TaggedIterator("some-tag")] @services : Enumerable(SomeInterface)); end

class Bar
  # Inject all services tagged with `"SomeInterface"`.
  def initialize(@[ADI::TaggedIterator] @services : Enumerable(SomeInterface)); end