https://kotlinlang.org logo
#compose
Title
# compose
a

Alderson Elliot

02/12/2022, 2:03 PM
When I jump to a new path, the viewmodel instance of the previous path does not seem to be recycled because onCleared is not called.
i

Ian Lake

02/12/2022, 3:38 PM
ViewModels are cleared when that destination is popped off the back stack, so it is expected that the state continues to be saved while the previous destination is still on the back stack
Note that the arguments for a destination are already available to a ViewModel if your ViewModel takes a
SavedStateHandle
parameter; there's no reason to manually pass them to a ViewModel
a

Alderson Elliot

02/13/2022, 1:02 AM
👌😊
3 Views