What is the best way to pass an object between 2 c...
# compose
s
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
I guess it depends on the use case
s
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
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
i
Here's the last conversation we had about this, including a link to the conversation before that as well: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1661402673918849?thread_ts=1661382233.146259&cid=CJLTWPH7S