- The Truth About ViewModel and rememberSavable: Configuration Changes vs . . .
Often, the best solution is to use ViewModel and rememberSaveable together For example, a ViewModel manages your main UI state, but a few critical fields use rememberSaveable so they’re restored even after process death
- ViewModel vs remember vs rememberSavable | by Shaheen Biradar - Medium
👉 Rule of thumb: Start with remember If you need persistence across config changes → upgrade to rememberSaveable If state belongs to business logic or is shared → put it in a ViewModel
- What is the difference between these two rememberSaveable calls
IMPORTANT: Because your session buyIn is a StateFlow and it is controlled by a ViewModel, which can survive configuration changes or any other restart-effect So both of your above declarations are unnecessary
- ViewModel vs rememberSaveable - Medium
Imaging that rememberSaveable is typed in brackets next to SavedInstanceState In short, it’s an alternative to onSaveInstanceState onRestoreInstanceState from Activity Fragment and
- Difference between remember and rememberSaveable
If the state is more complex or needs to be shared across multiple composables, using a ViewModel is often a better approach Unlike rememberSaveable, a ViewModel persists state across configuration changes and process recreation as long as the app is not explicitly killed
- ViewModel vs rememberSaveable | Akbolats Workshop
Just read it over here: https: medium com @iRYO400 viewmodel-vs-remembersaveable-47a72a32cb64 Last updated on Dec 1, 2022 Authors
- Save UI state in Compose - Android Developers
You should hoist the UI state to the ViewModel, not because it will handle configuration changes for free, but because it makes sense for your architecture However, a ViewModel instance does not survive system-initiated process death
- What are the exact criteria for choosing between ViewModel and plain . . .
rememberSaveable only remembers saveables in a Bundle ViewModel can hold more complex data and ongoing connections
|