Change theme
Help
Press space for more information.
Show links for this issue (Shortcut: i, l)
Copy issue ID
Previous Issue (Shortcut: k)
Next Issue (Shortcut: j)
Sign in to use full features.
Vote: I am impacted
Notification menu
Refresh (Shortcut: Shift+r)
Go home (Shortcut: u)
Pending code changes (auto-populated)
View issue level access limits(Press Alt + Right arrow for more information)
Unintended behavior
View staffing
Description
Component used: ViewModel Version used: 2.3.1 Devices/Android versions reproduced on: Emulator API 29
I just want to share a
ViewModel
object across navigation changes (using Jetpack Compose). I mean,ScreenA
is instantiatingMyViewModel
usingviewModel()
function. When I navigate (using Jetpack Navigation for Compose) toScreenB
and callviewModel()
from there, it returns a different instance.My current solution is a little ugly...
There's no
viewModel()
method that takes aViewModelStoreOwner
. It just always uses theLocalViewModelStoreOwner.current
.