Stefan Schmid
02/28/2022, 12:14 PMget
and getAll
still be available (and not deprecated)? Thanks for your help!arnaud.giuliani
03/01/2022, 8:38 AMVivek Modi
03/01/2022, 3:03 PMkhairil.ushan
03/02/2022, 8:14 PMTask
(non main thread). It gives me this error
Function doesn't have or inherit @Throws annotation and thus exception isn't propagated from Kotlin to Objective-C/Swift as NSError.
It is considered unexpected and unhandled instead. Program will be terminated.
Uncaught Kotlin exception: kotlin.native.IncorrectDereferenceException: illegal attempt to access non-shared org.koin.core.context.GlobalContext.KoinInstanceHolder@126fc48 from other thread
Anyone know how to work around this issue? Thank youJerry Preissler
03/05/2022, 7:49 PMSumit Sharma
03/12/2022, 8:02 AMRenaud
03/27/2022, 7:45 PMimport
_static_ org.koin.android.viewmodel.compat.ViewModelCompat.getViewModel;
is not available anymore.
→ How do we inject a Koin ViewModel in a Java class using Koin 3.2?Lilly
04/03/2022, 12:08 AMimport de.datacollect.protocol.di.protocolModule
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.RegisterExtension
import org.koin.test.check.checkKoinModules
import org.koin.test.junit5.AutoCloseKoinTest
import org.koin.test.junit5.mock.MockProviderExtension
class CheckModulesTest : KoinTest {
@JvmField
@RegisterExtension
val mockProvider = MockProviderExtension.create { clazz ->
}
@Test
fun verifyKoinApp() {
checkKoinModules(modules = protocolModule)
}
}
build.gradle.kts:
plugins {
kotlin("jvm")
`java-library`
}
depnedencies {
// Koin Core features
implementation "io.insert-koin:koin-core:$koin_version"
// Koin Test features
testImplementation "io.insert-koin:koin-test:$koin_version"
testImplementation "io.insert-koin:koin-test-junit5:$koin_version"
}
Rafael Costa
04/06/2022, 11:31 AMAustin Pederson
04/07/2022, 7:07 PMinitKoin
where Koin is unable to locate a KMM dependencyRasmus Plaubor
04/13/2022, 8:38 AMbobby
04/18/2022, 4:26 AMsingle
and factory
AFAIK, single
is used to create only one instance during the application lifetime, so when there is a request about the class instance, it will receive the same one, and only disposed when the application get terminate. while factory
instance will be created new one every time there is a request with the class, but it’s not clear to me when will it dispose. moreover, there is no explanation (after some research) for the memory usage for those two
can someone please explain about the memory usage? really appreciate it
my colleague really care about the memory usage, since our app is quite large, we try to save every memory we could
thank youlucapette
04/18/2022, 8:28 PMarnaud.giuliani
04/19/2022, 8:56 AMNathan Kleinschmidt
04/26/2022, 11:17 PMget()
, and the application crashes on startup. Is the documentation incomplete or am I missing something? I am trying this in a minimal Compose app using Koin v. 3.1.6
val appModule = module {
// MyViewModel ViewModel
viewModel { MyViewModel(get()) }
}
KamilH
04/28/2022, 5:03 AMkoin-annotation
project? I have a following declaration in my `Module`:
@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:
single(qualifier=null) { moduleInstance.allPlayersCache() }
single(qualifier=null) { moduleInstance.allPlayersByTourCache() }
and it reports a following error:
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
Jerry Preissler
04/29/2022, 12:38 PMAshu
05/08/2022, 2:36 PMstartKoin
part. Is there any "Application" kind of thing in common module? Again, I just started today so I may not know what I am talking about. Please help.Jan
05/09/2022, 9:01 PMJohn 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/12/2022, 7:17 AMpitpit
05/13/2022, 2:10 PMRak
05/16/2022, 7:40 AMSeb Jachec
05/16/2022, 11:58 AMclass SharedViewModel(val id: String?)
val sharedModule = module {
factoryOf(::SharedViewModel)
}
Android:
class AndroidViewModel(val sharedViewModel: SharedViewModel)
@Composable
fun MyScreen(
id: String?
) {
val viewModel = getViewModel<AndroidViewModel>(parameters = { parametersOf(id) })
}
val androidModule = module {
// Neither of these work here:
// viewModelOf(::AndroidViewModel)
// viewModel { params -> AndroidViewModel(get { parametersOf(params.getOrNull()) }) }
}
Marcin Wisniowski
05/16/2022, 2:55 PMVictor Kabata
05/18/2022, 8:44 AMlateinit var koin: Koin
fun main() {
koin = initKoin(enableNetworkLogs = false).koin //error here
return application {
MainScreen(applicationScope = this)
}
}
shared/commonMain/di/Koin.kt
fun initKoin(enableNetworkLogs: Boolean = false, appDeclaration: KoinAppDeclaration = {}) =
startKoin {
appDeclaration()
modules(commonModule(enableNetworkLogs), platformModule())
}
Fabian Vorholt
05/18/2022, 3:13 PMparameters
as key in ViewModelComposeExt
:
return remember(qualifier, parameters) {
scope.getViewModel(qualifier, { owner }, parameters)
}
But actually it isn't like that. It returns the same view model with old parameters. Is that behavior intended? Am I missing something?Ugurcan Yildirim
05/27/2022, 8:05 AMSeb Jachec
05/30/2022, 10:18 AMPageViewModel
) based on a parameter, but instead I’m getting the same instance no matter what parameter is provided. Has anyone got any pointers?
Simplified/shortened some code as an example:
_Android_:
class PageViewModel(val sharedViewModel: SharedPageViewModel): ViewModel() {}
@Component
fun ScreenContent(...) {
// ...
LazyRow(...) {
items(...) { PageContent(date = it) }
}
}
@Composable
fun PageContent(
date: LocalDate,
viewModel: PageViewModel = getViewModel(parameters = { parametersOf(date) })
) {
val viewModel: PageViewModel = getViewModel<AndroidViewModel>(parameters = { parametersOf(date) })
}
val androidModule = module {
viewModel { params -> PageViewModel(get { params }) }
}
Common/shared:
class SharedPageViewModel(val date: LocalDate)
val sharedModule = module {
factoryOf(::SharedPageViewModel)
}
alorma
06/02/2022, 8:01 AMalorma
06/02/2022, 8:01 AMphldavies
06/02/2022, 9:27 AM