Hi guys, how to send data class as an arguments in...
# compose
s
Hi guys, how to send data class as an arguments instead of each type in the data class? P.S -> I'm having list of items in home screen when onClick I need to pass the data as a class!
s
c
Yeah. I like the way that Ian Lake puts it. You should think of actions like urls and you would pass an id in a url, not the entire object.
a
It is very questionable. This implies that you have persistent storage. But you may not need one, and perhaps navigation should not be the only reason of introducing one. E.g. the app may be fully online (like Uber Eats). Ability to pass objects between screens may dramatically improve UX. E.g. when you open a restaurant menu cart, server may send fully detailed items. So you don't need additional requests when opening specific items from the menu.
1
c
Just hoist that object to another scope. I.e. if you have object in fragment a and want that object in fragment b, just put the object in the next scope up. Like the activity or navigation view model scope.
a
And then you open a heavy app like camera and your app is killed.
c
Parcelables are land mines. The binder transaction limit shrinks in every release.
a
Yes, it is still fine to pass a few thouand bytes. Anyway, glad there will always be ways to use parcelable.
Even with compose-navigation, we can always encode a parcelable into a string)))
i
Please don't
✔️ 2
a
It's a joke)