Chouten-App / Chouten-Android

Chouten App for Android
50 stars 3 forks source link

fix: viewmodel state preservation #9

Closed TobyBridle closed 1 year ago

TobyBridle commented 1 year ago

At the moment, if you leave the search page / info page, the preview viewmodel contains no data. We should preserve the viewmodel and only destroy it when we are creating a new viewmodel (of the same type) which contains different data. This would allow users to migrate from the search page to the info page without needing to re-type their query. We could look into using singletons for our viewmodels.

This would also fix the issue where multiple viewmodels are created on navigation (resulting in duplicate requests & thus longer loading times).

TobyBridle commented 1 year ago

https://youtu.be/h61Wqy3qcKg

Might be useful