Skip to content

Better handle empty multiple bindings. #249

@evant

Description

@evant

You may want to declare a multi-binding but provide no values. This is useful for cases where you want to 'extend' the set provided. Right now this is not possible because you have to declare at least one @IntoMap or @IntoSet in order for it to not complain that it can't provide the value. Dagger has 2 ways around this:

Add @Multibinds to the provider

@Multibinds abstract fun aSet(): Set<Foo>

Provide an empty collection with @ElementsIntoSet

@Provides @ElementsIntoSet
fun primeEmptyFooSet(): Set<Foo> = emptySet()

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions