Skip to content

Multibinder requires instances. #45

Closed
@richburdon

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))

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