is there a better alternative than this for naviga...
# compose
h
is there a better alternative than this for navigation compose? and please don't say you should send only id.
"product/{productId}?picture={productPicture}&name={prodName}&prodType={chatType}&groupId={groupId}&amount={prodAvailable}"
i
For reference, the last conversation about passing objects between screens, with links to the conversations before that as well: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1670606619523839?thread_ts=1670605775.341849&cid=CJLTWPH7S
c
Just a side question off of your original question @Hasan Nagizade Is there any reason why just sending an id is something you don't want to do?
s
In our case it's simply because we don't have an ID. We get some suggested search filters from a back-end in a JSON format that are built specifically for this user at this time based on other factors and we would like to pass these filters to another screen that performs the search itself. We've currently done this with a JSON-serialized query param, but I super don't like it. 😅
m
In our case it's simply because we don't have an ID
There is always an ID. If you don't get one, you make one as part of your in-memory representation. Whether that is an index or a timestamp or a UUID or something else is up to you. Your repository or other data layer caches the in-memory representation with the ID(s). You pass the ID around as needed to fetch the data from the repository.
s
For sure, but that would require actually having an in-memory representation. In this case, we don't do any local caching or anything, we just show what we get from the back-end. We could of course do that, but it would require some extra work.
I don't disagree that that would be a decent solution, though, and something we have considered doing already.
h
@Colton Idle because I don't have an api to get that data with id
c
You don't need a remote API. Just store your list of objects in your application scope or db and then pass the unique identifier from there. I understand your original question but there's just no reason why you should be trying to parcelize to just talk between two screens in your app. The memory space is all the same. Just pass an id and move your data source up to the activity, shared vm or application scope.