What is the best way to pass an object between 2 compose screens?
1. Save the object to room db and get it in the viewmodel with savestatehandle.
2. Share a single viewmodel between 2 screens pass the object in the viewmodel.
3. Convert the object to JSON and parse it on the next screen via custom NavType
Well?
m
mgrazianodecastro
09/18/2022, 2:42 AM
I guess it depends on the use case
s
Shafayat Bin Mamun
09/18/2022, 2:44 AM
I just want to simply pass my object to the next screen. Don't know which approach should I take. Don't want to just pass the id and make an extra api call.
m
mgrazianodecastro
09/18/2022, 2:45 AM
well, if you want resilience (like, the user shutting down the application in the next screen, and still being able to get the data back without an extra API call), saving in room is the way to go