John O'Reilly
05/11/2022, 1:14 PMsingleOf
in 3.2.0 release. Currently I have likes of following
single<PeopleInSpaceRepositoryInterface> { PeopleInSpaceRepository() }
single { PeopleInSpaceApi(get()) }
PeopleInSpaceApi
also has 2nd default param (url) which seems to cause an issue if I try following (error below). What's recommended way of dealing with this or is it better to use existing single
for cases like this?.
singleOf<PeopleInSpaceRepositoryInterface>(::PeopleInSpaceRepository)
singleOf(::PeopleInSpaceApi)
could not create instance for [Singleton:'com.surrus.common.remote.PeopleInSpaceApi']: org.koin.core.error.NoBeanDefFoundException: |- No definition found for class:'java.lang.String'. Check your definitions!
arnaud.giuliani
05/11/2022, 4:07 PMarnaud.giuliani
05/11/2022, 4:10 PMarnaud.giuliani
05/11/2022, 4:10 PMJohn O'Reilly
05/11/2022, 4:14 PMwbertan
05/11/2022, 4:38 PMString
? Wondering if can make use of a a proper type like data class ApiUrl(url: String)
(not sure if Koin supports the value class 🤔), then you can actually provide the definition of an ApiUrl
to Koin and the get
would resolve it.
We've in our project something similar (even we are not using the singleOf
, to make sure some things are given as it should (and TBH we also use some named
in some cases to differentiate)