in 3.2.0 release. Currently I have likes of following
Copy code
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
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!
a
arnaud.giuliani
05/11/2022, 4:07 PM
yes with default value in constructor, it will try to fill with get()
arnaud.giuliani
05/11/2022, 4:10 PM
then your url is not passed. Either you can pass it as injected param
arnaud.giuliani
05/11/2022, 4:10 PM
(or config object)
j
John O'Reilly
05/11/2022, 4:14 PM
ok, thanks....will take a look at doing something like that
w
wbertan
05/11/2022, 4:38 PM
@John O'Reilly your URL is of type
String
? 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