Add previousEntry alongside currentEntry to Navigator
tomczyn opened this issue · comments
Would it be possible to add a previousEntry
to Navigator
alongside currentEntry
?
We could then easily achieve sending data to the previous screen through the SavedStateHolder
. Here's an example use case based on StackOverflow question: https://stackoverflow.com/a/70631089/6690664
If you just want to passing objects as a result between scene, you can just use navigateForResult
with goBackWith
.
Good point, but with previousEntry
the communication can be more versatile, sending multiple values, sending values optionally (maybe send something, maybe don't) etc.
Navigate for the result indicates that we want a single result after navigation finishes. Also, coming from AndroidX navigation, people will be used to that behavior. What do you think?
A workaround to sending multiple values without previousEntry
is to wrap all the values as a class, and both navigateForResult
and goBackWith
are optional so you can pass something or nothing.
A previousEntry
would be nice to have, precompose already using it internally so why not.