Ofir Bar
12/27/2019, 10:44 PMOfir Bar
12/28/2019, 12:57 PMgetViewModel()
over using the lazy instantiation via by viewModel
?Ben Abramovitch
01/02/2020, 5:07 PMg4sarma
01/08/2020, 1:21 PMManuel Lorenzo
01/12/2020, 6:57 PMval databaseModule = module {
single { HeritageDatabase.getDatabase(get()) }
single { get<HeritageDatabase>().heritageDao() }
}
Paolo
01/16/2020, 3:20 PMMaikals
01/20/2020, 8:29 AMSmorg
01/22/2020, 4:25 AMval androidModule = module {
scope<MyActivity> {
scoped { Presenter() }
}
}
and I need to retrieve the Presenter
dependency in a fragment, which API can I use?Blundell
01/24/2020, 2:29 PMprivate val network1: Module
get() = module {
factory<RefreshAuthTokenInterceptor>() bind Interceptor::class
}
In Android Module 2)
private val network2: Module
get() = module {
factory<HeadersInterceptor>() bind Interceptor::class
factory<RetryInterceptor>() bind Interceptor::class
single<InterceptorFactory> {getAll<Interceptor>()}
}
App init:
startKoin {modules(listOf(network1, network2))}
In terms of gradle: App module depends on Module 1 which depends on Module 2
But the getAll<Interceptor>()
is only returning the 2 instances in the same Koin module. Is this expected behaviour? Is there anyway to get all 3 of the Interceptors?david.bilik
01/25/2020, 10:15 AMSavedState
mechanism. In current documentation there is no mention about that, so i thought that it is not yet release in stable version and I searched for that in alpha 2.1.0
where I actually found that for example here https://github.com/InsertKoinIO/koin/blob/2.1.0/koin-projects/koin-androidx-viewmodel/src/main/java/org/koin/androidx/viewmodel/ViewModelFactory.kt but there is nothing in changelog https://github.com/InsertKoinIO/koin/blob/2.1.0/CHANGELOG.md and samples are pretty sparse I think. Is there something im missing? If not, is it something you accept contributions for?LeoColman
02/05/2020, 6:23 PMMark
02/06/2020, 7:36 AMMark
02/09/2020, 4:39 AMContext
in via constructor or just accessing it inline with the help of a top-level property like:
val appContext by lazy {
GlobalContext.get().koin.get<Context>()
}
Since an application Context
is not mocked (I think!), is there any advantage to passing it into a constructor?Mark
02/12/2020, 11:50 AMMark
02/15/2020, 9:09 AMsingle
components? Does it mean the parametersOf() is only used the first time the component is fetched/injected? https://doc.insert-koin.io/#/koin-core/injection-parametersMark
02/17/2020, 2:19 PMstartKoin {}
and then and loading/unloading would be in rather non-standard scenarios (e.g. when there are large components and so need to free up memory). https://medium.com/better-programming/setting-up-android-modules-with-koin-962534395a3ekagomez
02/17/2020, 6:20 PMwhen (deeplink.lastPathSegment) {
BRANCHES_SEGMENT -> presenter.loadBranches()
else -> updateHomeState(screenState = HomeScreenState.HomeScreen)
}
the presenter is being injected on the Activity and on onStart and onCreate the presenter instance has not been initiliazed yetAstronaut4449
02/19/2020, 6:01 PMModel
class, a Controller
class and a View
class. There can be several instances of Model
in the application (scoped), but every one of these models has exactly one Controller
(scoped). Furthermore it shall be possible to have multiple instances of View
pointing to a pair of Model
and Controller
.
Afaik you can only tie a scope to a scope-id (string) koin.createScope<Model>(scopeId = "I have to provide an id")
. koin.createScope<Model>()
works, but only once since it is creating a scope-id from the class name. I want a scope to be bound to an instance. Is that somehow possible? I would love to see an API like this:
val scope1 = koin.createScope<Model>() // idea: scope should be tied to an instance of 'Model' instead of scopeId
val model1 = scope1.get<Model>() // scoped
val controller1 = scope1.get<Controller>() // scoped
val view11 = scope.get<View>() // factory
val view12 = scope.get<View>()
val scope2 = koin.createScope<Model>() // should create another scope tied to another instance of 'Model'
val model2 = scope1.get<Model>() // scoped
val controller2 = scope1.get<Controller>() // scoped
val view21 = scope.get<View>() // factory
val view22 = scope.get<View>()
arnaud.giuliani
02/24/2020, 2:58 PM2.1.0
is stable 🎉aipok
02/24/2020, 8:15 PMGlobalContext.get().koin.inject()
in 2.1.0 for Android?
I found KoinContextHandler.get()
or getKoin()
that works the same way, but which is expected to be used as replacement?Erik
02/26/2020, 1:31 PMstartKoin {}
. So basically I want to have a lib-private KoinApplication
/ Koin
instance. How do I approach this? It used to work on v2.0.1.ken
02/28/2020, 8:57 AMMark
03/01/2020, 3:54 AMianbrandt
03/01/2020, 7:34 PMdeclare { }
DSL from Koin Test documented here: https://doc.insert-koin.io/#/koin-test/testing?id=declaring-a-component-on-the-fly
Here are the project sources: https://github.com/sdkotlin/sd-kotlin-talks/blob/16f05dfb7292dcfa87e5df1c5d92b06c66cadba1/di-with-koin/src/it/kotlin/org/sdkotlin/koin/it/hello/HelloModuleIT.kt#L81
I tried single
, and factory
as in the docs, but both result in a:
Unresolved reference. None of the following candidates is applicable because of receiver type mismatch...I thought maybe it could be an issue with the fact that I was using an inline class (experimental) as the component type, but it fails to compile with a simple String type as well:
declare { single { "testing" } }
.
Am I doing something wrong here, or should I file a GitHub issue? Koin and Koin Test 2.1.1.aipok
03/04/2020, 7:42 AMkzotin
03/05/2020, 9:47 AM2.1.2
we're getting ERROR: Failed to resolve: org.koin:koin-androidx-scope:2.1.2
even though this dependency is not usedSaiedmomen
03/09/2020, 9:03 AMarnaud.giuliani
03/16/2020, 8:47 AMChills
03/21/2020, 7:45 AMsunnat629
03/23/2020, 2:36 PMfactory
and single
in Koin?