How to correctly create a dependency with generic ...
# koin
k
How to correctly create a dependency with generic type using
koin-annotation
project? I have a following declaration in my `Module`:
Copy code
@Singleton
fun allPlayersCache(): Cache<Unit, List<Player>> =
    ExpirableCache(LocalDateTimeCacheValidator())

@Singleton
fun allPlayersByTourCache(): Cache<Season, List<TeamPlayer>> =
    ExpirableCache(LocalDateTimeCacheValidator())
but it doesn’t work because it gets generated like that:
Copy code
single(qualifier=null) { moduleInstance.allPlayersCache() } 
single(qualifier=null) { moduleInstance.allPlayersByTourCache() }
and it reports a following error:
Copy code
Caused by: org.koin.core.error.DefinitionOverrideException: Already existing definition for [Singleton:'com.kamilh.utils.cache.Cache'] at com.kamilh.utils.cache.Cache::_root_
I guess in a classic koin I would need to use
named
right? It seems like it’s not available in
koin-annotation
a
yes interesting case. For now you need a @Named on it