You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When using a scope to resolve a viewmodel, then close the scope, create a new one and resolve viewmodel again, it will return the viewmodel that is created in the first scope, not a new one. Which I would expect?
To Reproduce
//class A
val fooScope = GlobalContext.get().getOrCreateScope("foo", named("foo"))
//Class B
val fooScope = GlobalContext.get().getOrCreateScope("foo", named("foo"))
val viewModel = resolveViewModel(
vmClass = T::class,
viewModelStore = this.viewModelStore, //same viewmodel store in all calls
extras = extrasProducer?.invoke() ?: MutableCreationExtras(),
parameters = parameters,
scope = widgetsScope,
qualifier = qualifier,
)
//Class A
fooScope.close()
//Class B creates scope and resolves viewmodel again
I would expect that a new scope would result in a fresh viewmodel, not in the existing one.
However, using System.identityhash shows that the scope is indeed renewed, but the resolved viewmodel is the same.
I am not sure if this is actually supported.
Koin module and version:
koin-3.5.0 (but also 3.4 and earlier)
The text was updated successfully, but these errors were encountered:
the thing is, it will depend on the viewModelStore. ViewModels are stored in this. This would explain why you find the same again. Perhaps, a scope key may be needed for this case.
Describe the bug
When using a scope to resolve a viewmodel, then close the scope, create a new one and resolve viewmodel again, it will return the viewmodel that is created in the first scope, not a new one. Which I would expect?
To Reproduce
I would expect that a new scope would result in a fresh viewmodel, not in the existing one.
However, using System.identityhash shows that the scope is indeed renewed, but the resolved viewmodel is the same.
I am not sure if this is actually supported.
Koin module and version:
koin-3.5.0 (but also 3.4 and earlier)
The text was updated successfully, but these errors were encountered: