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.reset() doesn't clear the PipelineProvider #465

Open
arnederuwe opened this issue Feb 1, 2017 · 6 comments
Open

router.reset() doesn't clear the PipelineProvider #465

arnederuwe opened this issue Feb 1, 2017 · 6 comments

Comments

@arnederuwe
Copy link

I'm submitting a bug report

  • Library Version:
    1.1.1

Please tell us about your environment:

  • Operating System:
    Windows 10

  • Node Version:
    6.9.1

  • NPM Version:
    3.10.8
  • Browser:
    all

  • Language:
    TypeScript 2.1

Current behavior:
When calling aurelia.setRoot(), this function resets the router. This way you can have 2 different route configs in your different app roots without manually having to clear the router when switching app roots. Right now the steps attached to the router remain active, causing bugs with authorisationSteps. I described my specific issue in detail in the following StackOverflow post: http://stackoverflow.com/questions/41956911/router-authorizestep-from-other-app-root-keeps-triggering

Expected/desired behavior:

  • What is the expected behavior?
    an aurelia.setRoot() should also do a pipelineProvider.reset()
    Unless i'm missing something, this can even be included in the router.reset() function

  • What is the motivation / use case for changing the behavior?
    It took some searching to figure out why my authorizeStep was still executing in another app root. I don't think the behavior is logical, when you switch roots, you want a whole 'new' router, without any steps you attached in another root.

If this can be fixed by just including the pipelineProvider.reset() into the router.clear() function, I would be happy to make a pull request for it.

@arnederuwe
Copy link
Author

arnederuwe commented Feb 2, 2017

Hi @EisenbergEffect
Am I right to add this to the router.clear()? Of course this would mean a breaking change for people currently relying on these steps not being removed, say you have some global step you want to be used on all roots, you would have to configure them in each individual router config you do after this change

@Deterus
Copy link

Deterus commented Feb 2, 2017

Thank you so much for discovering this @arnederuwe. I have been thinking that I was losing my mind by my auth step being re-triggered. Excited to see what the fix for this will be, but thank you so much for the instruction of how to work around.

@EisenbergEffect
Copy link
Contributor

EisenbergEffect commented Feb 2, 2017 via email

bigopon added a commit to bigopon/aurelia-router that referenced this issue Apr 21, 2019
@davismj
Copy link
Member

davismj commented Oct 3, 2019

while we wait on an official pull, this should work for now:

import { AppRouter } from 'aurelia-router';

const _reset = AppRouter.prototype.reset;
AppRouter.prototype.reset = function reset(this: any, ...args) {
    _reset.call(this, ...args);
    if(this.pipelineProvider) {
        this.pipelineProvider.reset();
    }
}

@bigopon
Copy link
Member

bigopon commented Oct 3, 2019

Its already in I think. Or at least in one of my hanging PR

@arnederuwe
Copy link
Author

I think it's in here :#637

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants