Support multiple keys within Map Multibindings
See original GitHub issueIt would be useful if when declaring a binding into a map, we could specify that one binding should be available under multiple keys.
Something like:
@Binds
@IntoMap
@TypeKey(Type.FOO)
@TypeKey(Type.BAR)
abstract Handler bindFooBarHandler(FooBarHandler handler);
or
@Binds
@IntoMap
@TypeKeys({Type.FOO, Type.BAR})
abstract Handler bindFooBarHandler(FooBarHandler handler);
Right now this can be accomplished with multiple @Binds
methods within a module, which is a little verbose.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:5
Top Results From Across the Web
Multibindings - Dagger
Dagger allows you to bind several objects into a collection even when the objects ... Keys must be unique, and any collision within...
Read more >Dagger 2 Multibindings Illustrated | by Elye - Medium
Dagger allows you to bind several objects into a collection even when ... Dagger 2 Multibinds into Map can only work with case...
Read more >Dagger by Tutorials, Chapter 14: Multibinding With Maps
In this chapter, you'll learn how to use multibinding with Map. ... You'll also create a simple custom key and use @KeyMap to...
Read more >Dagger2 Map multibinding : What do I provide for this java.util ...
You should inject the constructer of the viewModel class Example: @Inject public AuthViewModel(){} It should work fine.
Read more >Understanding Dagger 2 Multibindings + ViewModel
says roughly: “inject this object into a Map ( @IntoMap annotation) using UserViewModel.class as key, and a Provider that will build a ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
SOURCE
retention will not always work if the module is in a different compilation from the@Component
that installs the module. But this is a point, just wanted to correct the record.Hi guys,
I tried to use repeatable annotations from java 8 and I faced with issue.
Firstly I defined my custom annotation as map key like this (from tutorial):
After that I tried to bind same object to a few keys:
Compiler said me that I should mark my annotation with Repeatable one This annotation this available since API level 24 so I can’t use multiple keys in my project.
Even in 2k19 we should support devices with API level 19 or even API level 17 so it would be great to support multiple keys from dagger’s side.