Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigator - Guard against a goTo to the current screen #1331

Merged
merged 11 commits into from
Apr 13, 2024
Merged

Conversation

stagg
Copy link
Collaborator

@stagg stagg commented Apr 8, 2024

Implements #1317 with the bool result return approach. Open to also going with the passed in callback which was another suggested approach.

@stagg stagg marked this pull request as ready for review April 11, 2024 23:46
@stagg stagg requested a review from ZacSweers April 11, 2024 23:46
backStack.push(screen)
override fun goTo(screen: Screen): Boolean {
return if (peek() != screen) {
backStack.push(screen)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we mirror this in the back stack push()? I actually wonder if this would be better off as a back stack configuration

override fun goTo(screen: Screen): Boolean {
val res = delegate.goTo(screen)
if (res) {
goToEvents.add(screen)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of me thinks this should always log but we could offer a way to read the transaction result?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a GoToEvent to cover this 👍🏻

@stagg stagg requested a review from ZacSweers April 13, 2024 04:08
@stagg stagg added this pull request to the merge queue Apr 13, 2024
Merged via the queue into main with commit b63bbdc Apr 13, 2024
5 checks passed
@stagg stagg deleted the js-nav-goto-guard branch April 13, 2024 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants