tapchicoma
03/14/2019, 1:27 PMdeclare { .. }
in 2.0.0-beta1
koin test? Is it removed and what is the replacement?tapchicoma
03/14/2019, 2:45 PMdata class One(val item: String)
data class Two(val one: One)
val testModule = module {
scope("TEST_SCOPE") {
scoped { One("zzz") }
scoped { Two(get()) }
}
}
nwh
03/14/2019, 6:49 PMOkHttpClient
declared as a single dependency, and the Retrofit API as another (which uses get()
for the client). I found a mock setup for OkHttp that uses an interceptor to return a custom response, but I can't figure out how to set it up with koin. How should I do it? When I use declareMock
I start getting errors in OkHttp..
When I copy an identical declaration from the declareMock
to single
in a non-test environment, everything works exactly as expected. It is only when using the declareMock
that there is a problem. Here's the difference in object creation order:
Mock:
----
Creating client (mock)
Created client (mock)
Creating API wrapper
Creating ProPublica API
Created ProPublica API
Created API wrapper
Real:
----
Creating API wrapper
Creating ProPublica API
Creating client (real)
Created client (real)
Created ProPublica API
Created API wrapper
arnaud.giuliani
03/15/2019, 8:39 AMkodal
03/18/2019, 8:11 AMMaikals
03/18/2019, 4:22 PMkenkyee
03/19/2019, 5:52 PMkenkyee
03/19/2019, 5:55 PMkenkyee
03/19/2019, 7:46 PMbastienC
03/20/2019, 4:18 PME/KOIN: [ERROR] - Error while resolving instance for class 'com.x.domain.navigation.Navigator' - error: org.koin.error.NoScopeException: Definition 'Scope [name='Navigator',class='com.x.domain.navigation.Navigator']' has to be used with a scope. Please create and specify a scope to use with your definition
<- but navigator is scoped, it happend when we try to restart the current activity (with activity.finish() -> startActivity()), any idea ?Jordan
03/20/2019, 9:44 PMwoodii
03/27/2019, 8:09 AMbdawg.io
03/27/2019, 7:05 PMil_agent
03/29/2019, 10:47 AMtapchicoma
03/29/2019, 2:01 PMval someModule = module {
scope(named("some")) {
scoped { SomeClass(get()) }
}
single<SomeFunctionTypealias> { { incoming -> get<SomeOtherClass>().process(incoming) } }
}
where SomeClass
has SomeFunctionTypealias
as constructor param.
Will in this case Koin call get<SomeOtherClass>()
on scope or will it be got from global scope? I suspect a leak in my app because of thismmaillot
04/05/2019, 12:49 PMby sharedViewModel()
to inject the view model. But I want to create my ViewModel with an argument provided via intent in the activity. Is it possible ?Denys
04/08/2019, 6:31 PMarnaud.giuliani
04/09/2019, 7:50 AMnwh
04/09/2019, 5:58 PMval obj: Type = get()
versus
val obj: Type by inject()
Is it just a decision based on if I want it to be lazy or not? I'm not sure what to consider there.sahil Lone
04/10/2019, 11:03 AMmodule {
single { appConfig } ,
single { (appConfig: AppConfig) ->
appConfig.dbConfig
}
single { (dbConfig: DbConfig) ->
val config = HikariConfig()
config.jdbcUrl = "${dbConfig.jdbcUrl}/${dbConfig.database}"
config.username = dbConfig.username
config.password = dbConfig.password
HikariDataSource(config)
} bind DataSource::class
single { (dataSource: DataSource) ->
Database.connect(dataSource)
}
}
Exception in thread "main" org.koin.core.error.InstanceCreationException: Could not create instance for [type:Single,class:'com.zaxxer.hikari.HikariDataSource', classes:javax.sql.DataSource]
Caused by: org.koin.core.error.NoParameterFoundException: Can't get parameter value #0 from org.koin.core.parameter.DefinitionParameters@4fe01803nwh
04/11/2019, 6:12 PMinline fun <T> withKoin(crossinline block: KoinComponent.() -> T): T {
return object : KoinComponent { val v = block() }.v
}
sanogueralorenzo
04/20/2019, 4:27 AMname = "x"
is no longer used and it is asking for a qualifier (+ I can see a named function in autocomplete). How should it be now?
Also, what is the advantage of this? To not require strings for names like List<String> and put that as a type of the Qualifier?
Thanks!Tmpod
04/26/2019, 7:39 PMfileProperties
work in Koin? I can't seem to make the framework find the file...Tmpod
04/26/2019, 7:39 PMquver
05/03/2019, 5:22 PMarnaud.giuliani
05/06/2019, 8:48 AMarnaud.giuliani
05/06/2019, 10:03 AMbastienC
05/09/2019, 9:53 AMsingle {
DeviceController(
InternetManager(androidContext()) as InternetDataSource,
DeviceInformation(androidContext()) as DeviceInformationDataSource
)
} bind Device.Connection::class bind Device::class
was working before on 2.0.0-rc1, seems not working anymore on 2.0.0-GA, any idea ?arnaud.giuliani
05/09/2019, 10:28 AMgetKoin().bind<DeviceController,Connection>
instead @bastienCarnaud.giuliani
05/10/2019, 6:07 AMmodule {
single { Simple.Component1() } bind Simple.ComponentInterface1::class
single { Simple.Component2() } bind Simple.ComponentInterface1::class
single { Simple.UserComponent(bind<Simple.Component1, Simple.ComponentInterface1>()) }
}
- you can get directly the instances with get<Simple.Component1>()
, get<Simple.Component2>()
- get<Simple.ComponentInterface1>()
will throw an error and tell you to use bind
because can’t choose between the 2 definitions
- you can use bind<>()
to resolve a component in the DSL
- getAll<Simple.ComponentInterface1>()
give us the 2 instancesarnaud.giuliani
05/10/2019, 6:07 AMmodule {
single { Simple.Component1() } bind Simple.ComponentInterface1::class
single { Simple.Component2() } bind Simple.ComponentInterface1::class
single { Simple.UserComponent(bind<Simple.Component1, Simple.ComponentInterface1>()) }
}
- you can get directly the instances with get<Simple.Component1>()
, get<Simple.Component2>()
- get<Simple.ComponentInterface1>()
will throw an error and tell you to use bind
because can’t choose between the 2 definitions
- you can use bind<>()
to resolve a component in the DSL
- getAll<Simple.ComponentInterface1>()
give us the 2 instancessloydev
05/10/2019, 6:50 AMval instance: Simple.ComponentInterface1 = bind<Simple.Component1, Simple.ComponentInterface1>()
, is that right?arnaud.giuliani
05/10/2019, 7:13 AMsloydev
05/10/2019, 7:14 AMval instance: Simple.ComponentInterface1 = get<Simple.Component1>()
? Or just different API?arnaud.giuliani
05/10/2019, 8:10 AMkenkyee
05/10/2019, 2:03 PMarnaud.giuliani
05/10/2019, 2:09 PMFeature
or Plugin
for examplekenkyee
05/10/2019, 2:20 PM