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

remove destinationId and replace it with the class name of routes #46

Merged
merged 3 commits into from Feb 14, 2022

Conversation

gabrielittner
Copy link
Member

@gabrielittner gabrielittner commented Feb 11, 2022

Instead of having destinationId in the public API we will create ids internally based on the hashCode of the fully qualified class name of a route. Most APIs already had everything we need there were 2 changes other than removing the id from the destinations:

  • navigateTo with pop up to is now navigateToOnTopOf, a call would be navigatoToOnTopOf<FooDirections>(BarDirections()) not super happy with the name here because it could also be interpreted as go to foo and then to bar. Also if you pass inclusive = true then Foo would also be removed and bar would be on top of foo's parent
  • navigateBack with pop up to is now navigateBackTo, e.g. navigateBackTo<FooDirections>(), here it works better

Copy link
Contributor

@kboyarshinov kboyarshinov left a comment

Choose a reason for hiding this comment

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

NavigateToOnTopOfEvent, NavigateToOnTopOfRootEvent, NavigateBackAndThenToEvent feel to me as combination of other events and probably should not be in the library's API.

Although BackToRootEvent is similar to NavigateToRootEvent it can stay since it's a simpler alias to basically reset to current root.

What if instead we have a way to define a sequence of events or ensure that all events that sent will be processed (not only the last one sent) ?

What do you think?

*/
@VisibleForTesting(otherwise = PACKAGE_PRIVATE)
public data class NavigateToOnTopOfRootEvent(
internal val route: NavRoute,
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be NavRoot?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but I'll remove the extra method after #47 is merged (will update this pr then)

* itself will also be popped of the back stack. Then navigates to the given [route].
*/
@VisibleForTesting(otherwise = PACKAGE_PRIVATE)
public data class NavigateBackAndThenToEvent(
public data class NavigateToOnTopOfEvent(
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't this event be implemented as two events, navigate back with popUpTo and inclusive, and then using regular NavigateTo some destination?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. The main reason that we have it as an extra event is that it is also a possibility with navcontroller (calling navigate with options that use popUpTo). It's a bit nicer because it doesn't rely on automatically merging multiple nav operations into one

* will also be popped of the back stack.
*/
@VisibleForTesting(otherwise = PACKAGE_PRIVATE)
public data class BackToRootEvent(
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't it the same as NavigateToRootEvent to the current root of backstack?

@gabrielittner
Copy link
Member Author

As mentioned the duplication for root will go away with #47.

What if instead we have a way to define a sequence of events or ensure that all events that sent will be processed (not only the last one sent) ?

This is already possible. You can for example call navigateTo multiple times to build a synthetic back stack. So it should probably be fine to replace navigatoToOnTopOf with just making 2 calls

@kboyarshinov kboyarshinov self-requested a review February 14, 2022 10:30
Copy link
Contributor

@kboyarshinov kboyarshinov left a comment

Choose a reason for hiding this comment

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

This is already possible. You can for example call navigateTo multiple times to build a synthetic back stack. So it should probably be fine to replace navigatoToOnTopOf with just making 2 calls

I guess then we can gradually replace it in our codebase and then clean it up 👍

@gabrielittner
Copy link
Member Author

Merged with master and marked navigatoToOnTopOf as obsolete

@gabrielittner gabrielittner merged commit 246b954 into main Feb 14, 2022
@gabrielittner gabrielittner deleted the remove-destination-ids branch February 14, 2022 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants