Lukasz Kalnik
08/12/2022, 12:42 PMMoritz Post
08/23/2022, 9:28 AMLukasz Kalnik
08/23/2022, 9:30 AMMoritz Post
08/23/2022, 9:30 AMLukasz Kalnik
08/23/2022, 9:31 AMMoritz Post
08/23/2022, 9:31 AMLukasz Kalnik
08/23/2022, 9:32 AMMoritz Post
08/23/2022, 9:32 AMLukasz Kalnik
08/23/2022, 9:34 AMgetKoin().createScope()
? But when will the session be finished? Will it be automatically finished when I leave the starting fragment?Moritz Post
08/23/2022, 9:36 AMLukasz Kalnik
08/23/2022, 9:37 AMMoritz Post
08/23/2022, 9:37 AMprivate val myModule = module {
scope<Session> {
scoped { MySession() }
}
}
private var mySessionScope: Scope? = null
private val viewModelModule = module {
viewModel {
mySessionScope = getKoin().createScope<Session>()
with(requireNotNull(mySessionScope)) {
ScreenAViewModel(get(), get()).apply {
addCloseable { close() }
}
}
}
viewModel {
with(requireNotNull(mySessionScope)) {
ScreenBViewModel(get())
}
}
viewModel {
with(requireNotNull(mySessionScope)) {
ScreenCViewModel(get())
}
}
}
get()
calls would be able to resolve the shared MySession
.Lukasz Kalnik
08/23/2022, 9:41 AMaddCloseable
before...Moritz Post
08/23/2022, 9:41 AMLukasz Kalnik
08/23/2022, 9:43 AMMoritz Post
08/23/2022, 9:45 AMLukasz Kalnik
08/23/2022, 9:45 AMMoritz Post
08/23/2022, 9:45 AM