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

router: change URL in between navigating & navigated #4974

Merged
merged 2 commits into from
May 18, 2021

Conversation

stephanwlee
Copy link
Contributor

With this change, we now modify the URL before navigated is fired so
all the downstream can send request right away without having to confirm
that the route change is indeed reflected in the URL bar.

Context: previously, our router modified the URL only when the
navigated action is fired. Often, this action is listened to by many
views/effects so they can do a cleanup or a data fetch for the new
route. Now, because the URL was only modified after navigated is
fired, there could be a timing issues where, depending on the order of
execution, we can be making requests to the unmodified URL, causing
issues.

Now, we are changing the semantics of the navigated to really really
mean, 'hey, the navigation is now complete and everything is settled'.

Tested this change internally.

@stephanwlee stephanwlee requested a review from psybuzz May 14, 2021 17:34
@google-cla google-cla bot added the cla: yes label May 14, 2021
@stephanwlee
Copy link
Contributor Author

To reviewer: recommend turning on 'ignore white space change' option.

Copy link
Contributor

@psybuzz psybuzz left a comment

Choose a reason for hiding this comment

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

Thanks for testing it internally. I tested it in OSS and looks good

navigationOptions: {
replaceState: false,
},
navigateAndExpect(activeRoute, {
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on this call, the type for the first parameter to navigateAndExpect on L645 should be Navigation | Route, not Navigation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed; thanks for catching it.

With this change, we now modify the URL before `navigated` is fired so
all the downstream can send request right away without having to confirm
that the route change is indeed reflected in the URL bar.

Context: previously, our router modified the URL only when the
`navigated ` action is fired. Often, this action is listened to by many
views/effects so they can do a cleanup or a data fetch for the new
route. Now, because the URL was only modified after `navigated ` is
fired, there could be a timing issues where, depending on the order of
execution, we can be making requests to the unmodified URL, causing
issues.

Now, we are changing the semantics of the `navigated` to really really
mean, 'hey, the navigation is now complete and everything is settled'.

Tested this change internally.
@stephanwlee
Copy link
Contributor Author

Tested once more; since unclear whether this will break our odd variant, I will merge this, sync it, then simmer it so it can be reverted in isolation.

@stephanwlee stephanwlee merged commit 8223f98 into tensorflow:master May 18, 2021
@stephanwlee stephanwlee deleted the router branch May 18, 2021 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants