Skip to content

Multibinder requires instances. #45

Description

@richburdon

I often use multi-binding where I want to use DI to create instances of the sequence -- hence I can't bind instances directly to the sequence key. My workaround is the utility class below, but it feels like this should be built into the framework (esp. since ListOfProviders is markes @Private)

binder.multibind(Test.SEQ_KEY, ClassProviderList([MyClass])) # Not an instance.

class ClassProviderList(ListOfProviders):
    def __init__(self, classes):
        super(ClassProviderList, self).__init__()
        for cls in classes:
            self.append(ClassProvider(cls))

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

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions