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

Stopping and starting page.js has some odd results. #567

Open
arne-strout-icrossing opened this issue Aug 6, 2020 · 0 comments
Open

Stopping and starting page.js has some odd results. #567

arne-strout-icrossing opened this issue Aug 6, 2020 · 0 comments

Comments

@arne-strout-icrossing
Copy link

The use case would be to re-dispatch if a user is already on a url that matches the route you just added to page.js but your code to add the handler ran after page.js started. In other threads the solution suggested has been to perform a page.stop() followed by page.start().

This works, but in a very specific situation it fails (at least for me). Here's a psuedo implementation:

page('/myroute/*',(context,next)=>{
   if(next)next();
});
page.start()
page('/myroute/other/*',(context,next)=>{

    if(next)next();
});

page.stop();
page.start();

page('/myroute/other/beans');
// this will reload the page at the url mydomain/myroute/other instead of updating the url

Not sure as to why this is happening, something not being cleaned up when start() is subsequent to stop() maybe?
I solved by removing if(next)next(); from my second handler, but that shouldn't be necessary.

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

1 participant