flow-and-components-documentation icon indicating copy to clipboard operation
flow-and-components-documentation copied to clipboard

Explain the difference between `rerouteTo` and `forwardTo`

Open mvysny opened this issue 5 years ago • 2 comments
trafficstars

The https://vaadin.com/docs/v14/flow/routing/tutorial-routing-lifecycle.html#rerouting docs doesn't help: the docs for forward and rerouteTo are almost identical.

The BeforeEnterEvent's javadoc doesn't explain the difference at all also:

  • rerouteTo(): Reroutes the navigation to show the given component instead of the component that is currently about to be displayed.
  • forwardTo(): Forward the navigation to show the given component instead of the component that is currently about to be displayed.

The same thing, just 'forward' instead of 'reroutes'.

Update the documentation to mention the difference between the two.

mvysny avatar Sep 23 '20 11:09 mvysny

Just guessing: could it be that rerouteTo updates the browser's URL while forwardTo does not?

mvysny avatar Sep 23 '20 11:09 mvysny

Yes:

  • rerouteTo() doesn't change the browser's URL
  • forwardTo() also changes the browser's URL

mvysny avatar Sep 23 '20 11:09 mvysny