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

Feature: reload + navigate to route #24

Open
ahamid opened this issue May 10, 2017 · 4 comments
Open

Feature: reload + navigate to route #24

ahamid opened this issue May 10, 2017 · 4 comments

Comments

@ahamid
Copy link

ahamid commented May 10, 2017

go will navigate to specified route
reload will (optionally) reload and navigate to current route

It would be handy to have support for reloading targeting a different destination, e.g.:

const dest = router.href(router.registry.get(DEST_ROUTE_NAME), {param})
let currentRoute = router.current.route
router.pushState({}, currentRoute.title, router.href(currentRoute, { param: currentParam }))
window.location.href = dest // instead of reload
@kcrwfrd
Copy link
Owner

kcrwfrd commented May 11, 2017

I think this ought to do what you want:

router.go(destination, { param }) && router.reload({}, true)

The URL and the current route params will change (with a call to pushState), but then the hard reload will execute before the promise-based route transition does.

Is that satisfactory?

@ahamid
Copy link
Author

ahamid commented May 11, 2017

I see, that makes sense! Thanks, I'll give that a shot.

@ahamid
Copy link
Author

ahamid commented May 12, 2017

Hmm, this has the effect of pushing the target path, with current parameter on the stack before navigating to target path with target parameter (therefore back button takes you to new synthetic location), but it's probably fine.

e.g. a/1 -> b/2
stack:
b/2
b/1
a/1

@kcrwfrd
Copy link
Owner

kcrwfrd commented May 12, 2017

Hmm that's weird. Looking at the source, there might be a bug with the reload method, but I wouldn't expect it to manifest like that.

Does this work?

router.go(destination, { param }) && window.location.reload()

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

No branches or pull requests

2 participants