Skip to content

Default definitions with tags #20

Description

@ilyapuchka

Currently we can register few definitions with different tags and one with no tag, which will be used as a default if we try to resolve component using unknown tag.

But it does not work the other way - if we don't register definition without tag we will not be able to resolve component without providing tag.

Would it be useful to be able to setup definition with tag as a default and later be able to resolve it without setting tag?

container.register(tag: "facebook", useByDefault: true) { FacebookOAuth() as OAuth }
container.register(tag: "twitter") { TwitterOAuth() as OAuth }
container.register(tag: "google") { GoogleOAuth() as OAuth }

container.resolve() as OAuth // will resolve FacebookOAuth

container.register() { TwitterOAuth() as OAuth } // will override previous default
container.resolve("tumblr") as OAuth // should not resolve, because user explicitly specified unknown tag

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions