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

feat(router): add pathParamsChange mode for runGuardsAndResolvers #26861

Closed
wants to merge 2 commits into
base: master
from

Conversation

@jasonaden
Copy link
Contributor

jasonaden commented Oct 30, 2018

This option means guards and resolvers will ignore changes to optional
parameters such as query and matrix params. When the path or any path
params change, guards and resolvers will be run.

Related to discussion in #18253
FW-560 #resolve

@googlebot googlebot added the cla: yes label Oct 30, 2018

@jasonaden jasonaden force-pushed the jasonaden:FW-560_never_run_guards_and_resolvers branch from 74fd3a4 to 2b6d09a Oct 30, 2018

@mary-poppins

This comment has been minimized.

Copy link

mary-poppins commented Oct 30, 2018

@mary-poppins

This comment has been minimized.

Copy link

mary-poppins commented Oct 30, 2018

@jasonaden jasonaden requested review from IgorMinar and benlesh Oct 30, 2018

@jasonaden jasonaden force-pushed the jasonaden:FW-560_never_run_guards_and_resolvers branch from 2b6d09a to 080005b Oct 30, 2018

@jasonaden

This comment has been minimized.

Copy link
Contributor Author

jasonaden commented Oct 30, 2018

@mary-poppins

This comment has been minimized.

Copy link

mary-poppins commented Oct 30, 2018

Show resolved Hide resolved tools/public_api_guard/router/router.d.ts Outdated
@benlesh

This comment has been minimized.

Copy link
Contributor

benlesh commented Oct 31, 2018

This PR fixes 237 tests in core:test.

master
1264 specs, 776 failures, 2 pending specs

this PR
1264 specs, 539 failures, 2 pending specs
@JoostK

This comment has been minimized.

Copy link
Contributor

JoostK commented Oct 31, 2018

This PR fixes 237 tests in core:test.

master
1264 specs, 776 failures, 2 pending specs

this PR
1264 specs, 539 failures, 2 pending specs

@benlesh How? Did your comment end up with the correct PR?

@jasonaden jasonaden force-pushed the jasonaden:FW-560_never_run_guards_and_resolvers branch from 080005b to 2f4b03b Nov 1, 2018

@jasonaden jasonaden changed the title feat(router): add initialNavOnly mode for runGuardsAndResolvers feat(router): add pathParamsChange mode for runGuardsAndResolvers Nov 1, 2018

@mary-poppins

This comment has been minimized.

Copy link

mary-poppins commented Nov 1, 2018

@jasonaden

This comment has been minimized.

Copy link
Contributor Author

jasonaden commented Nov 1, 2018

Updated this PR to better align with how guards and resolvers should be used. The option changed to pathParamsChange, meaning that guards and resolvers will be run when either the path or any path params change. This will effectively ignore all optional parameters including matrix and URL params.

@jasonaden

This comment has been minimized.

Copy link
Contributor Author

jasonaden commented Nov 1, 2018

Updated Presubmit

@kara

This comment has been minimized.

Copy link
Contributor

kara commented Nov 1, 2018

@jasonaden Can you check out the Travis failures? They look like they could be related.

@jasonaden jasonaden force-pushed the jasonaden:FW-560_never_run_guards_and_resolvers branch from 2f4b03b to 166c7a8 Nov 5, 2018

@jasonaden

This comment has been minimized.

Copy link
Contributor Author

jasonaden commented Nov 5, 2018

Updated Presubmit

@jasonaden jasonaden force-pushed the jasonaden:FW-560_never_run_guards_and_resolvers branch from 166c7a8 to 59dfa80 Nov 13, 2018

@mary-poppins

This comment has been minimized.

Copy link

mary-poppins commented Nov 13, 2018

@mary-poppins

This comment has been minimized.

Copy link

mary-poppins commented Nov 14, 2018

@ngbot

This comment has been minimized.

Copy link

ngbot bot commented Nov 14, 2018

I see that you just added the PR action: merge label, but the following checks are still failing:
    failure status "ci/circleci: test_aio_tools" is failing
    pending status "google3" is pending
    pending status "continuous-integration/travis-ci/pr" is pending
    pending status "ci/circleci: integration_test" is pending

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken master, please try rebasing to master and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

jasonaden added a commit to jasonaden/angular that referenced this pull request Dec 3, 2018

jasonaden added a commit to jasonaden/angular that referenced this pull request Dec 3, 2018

jasonaden added a commit to jasonaden/angular that referenced this pull request Dec 4, 2018

feat(router): add pathOrQueryParamsChange mode for runGuardsAndResolvers
This option means guards and resolvers will ignore changes to matrix parameters. Guards and resolvers will be rerun when the path changes, when path parameters change, or when query parameters change.

Related to angular#26861 angular#18253

Related to discussion in angular#18253

jasonaden added a commit to jasonaden/angular that referenced this pull request Dec 4, 2018

feat(router): add pathOrQueryParamsChange mode for runGuardsAndResolvers
This option means guards and resolvers will ignore changes to matrix parameters. Guards and resolvers will be rerun when the path changes, when path parameters change, or when query parameters change.

The primary use case for such a mode is when updating the UI and getting the URL to be in sync with local changes. For example, if displaying a sortable table, changing the sort direction is often handled by the table itself. But you would want to update the URL to be in sync with what's being displayed to the user. As long as the table sort direction is stored as a matrix parameter, you can use this option to update the URL without causing the overhead of re-running guards and resolvers.

Related to angular#26861 angular#18253

jasonaden added a commit to jasonaden/angular that referenced this pull request Dec 4, 2018

feat(router): add pathParamsOrQueryParamsChange mode for runGuardsAnd…
…Resolvers

This option means guards and resolvers will ignore changes to matrix parameters. Guards and resolvers will be rerun when the path changes, when path parameters change, or when query parameters change.

The primary use case for such a mode is when updating the UI and getting the URL to be in sync with local changes. For example, if displaying a sortable table, changing the sort direction is often handled by the table itself. But you would want to update the URL to be in sync with what's being displayed to the user. As long as the table sort direction is stored as a matrix parameter, you can use this option to update the URL without causing the overhead of re-running guards and resolvers.

Related to angular#26861 angular#18253

jasonaden added a commit to jasonaden/angular that referenced this pull request Dec 5, 2018

feat(router): add pathParamsOrQueryParamsChange mode for runGuardsAnd…
…Resolvers

This option means guards and resolvers will ignore changes to matrix parameters. Guards and resolvers will be rerun when the path changes, when path parameters change, or when query parameters change.

The primary use case for such a mode is when updating the UI and getting the URL to be in sync with local changes. For example, if displaying a sortable table, changing the sort direction is often handled by the table itself. But you would want to update the URL to be in sync with what's being displayed to the user. As long as the table sort direction is stored as a matrix parameter, you can use this option to update the URL without causing the overhead of re-running guards and resolvers.

Related to angular#26861 angular#18253

jasonaden added a commit to jasonaden/angular that referenced this pull request Dec 5, 2018

feat(router): add pathParamsOrQueryParamsChange mode for runGuardsAnd…
…Resolvers

This option means guards and resolvers will ignore changes to matrix parameters. Guards and resolvers will be rerun when the path changes, when path parameters change, or when query parameters change.

The primary use case for such a mode is when updating the UI and getting the URL to be in sync with local changes. For example, if displaying a sortable table, changing the sort direction is often handled by the table itself. But you would want to update the URL to be in sync with what's being displayed to the user. As long as the table sort direction is stored as a matrix parameter, you can use this option to update the URL without causing the overhead of re-running guards and resolvers.

Related to angular#26861 angular#18253

IgorMinar added a commit that referenced this pull request Dec 5, 2018

jasonaden added a commit to jasonaden/angular that referenced this pull request Dec 5, 2018

feat(router): add pathParamsOrQueryParamsChange mode for runGuardsAnd…
…Resolvers

This option means guards and resolvers will ignore changes to matrix parameters. Guards and resolvers will be rerun when the path changes, when path parameters change, or when query parameters change.

The primary use case for such a mode is when updating the UI and getting the URL to be in sync with local changes. For example, if displaying a sortable table, changing the sort direction is often handled by the table itself. But you would want to update the URL to be in sync with what's being displayed to the user. As long as the table sort direction is stored as a matrix parameter, you can use this option to update the URL without causing the overhead of re-running guards and resolvers.

Related to angular#26861 angular#18253

IgorMinar added a commit that referenced this pull request Dec 5, 2018

feat(router): add pathParamsOrQueryParamsChange mode for runGuardsAnd…
…Resolvers (#27464)

This option means guards and resolvers will ignore changes to matrix parameters. Guards and resolvers will be rerun when the path changes, when path parameters change, or when query parameters change.

The primary use case for such a mode is when updating the UI and getting the URL to be in sync with local changes. For example, if displaying a sortable table, changing the sort direction is often handled by the table itself. But you would want to update the URL to be in sync with what's being displayed to the user. As long as the table sort direction is stored as a matrix parameter, you can use this option to update the URL without causing the overhead of re-running guards and resolvers.

Related to #26861 #18253

PR Close #27464

jasonaden added a commit to jasonaden/angular that referenced this pull request Dec 14, 2018

feat(router): add predicate function mode for runGuardsAndResolvers
This option means guards and resolvers will ignore changes when a provided predicate function returns `false`. This supports use cases where an application needs to ignore some param updates but not others. For example, changing a sort param in the URL might need to be ignored, whereas changing the a `project` param might require re-run of guards and resolvers.

Related to angular#26861 angular#18253 angular#27464

jasonaden added a commit to jasonaden/angular that referenced this pull request Dec 17, 2018

feat(router): add predicate function mode for runGuardsAndResolvers
This option means guards and resolvers will ignore changes when a provided predicate function returns `false`. This supports use cases where an application needs to ignore some param updates but not others. For example, changing a sort param in the URL might need to be ignored, whereas changing the a `project` param might require re-run of guards and resolvers.

Related to angular#26861 angular#18253 angular#27464

mhevery added a commit that referenced this pull request Dec 18, 2018

feat(router): add predicate function mode for runGuardsAndResolvers (#…
…27682)

This option means guards and resolvers will ignore changes when a provided predicate function returns `false`. This supports use cases where an application needs to ignore some param updates but not others. For example, changing a sort param in the URL might need to be ignored, whereas changing the a `project` param might require re-run of guards and resolvers.

Related to #26861 #18253 #27464

PR Close #27682

IgorMinar added a commit to IgorMinar/angular that referenced this pull request Dec 19, 2018

feat(router): add predicate function mode for runGuardsAndResolvers (a…
…ngular#27682)

This option means guards and resolvers will ignore changes when a provided predicate function returns `false`. This supports use cases where an application needs to ignore some param updates but not others. For example, changing a sort param in the URL might need to be ignored, whereas changing the a `project` param might require re-run of guards and resolvers.

Related to angular#26861 angular#18253 angular#27464

PR Close angular#27682

IgorMinar added a commit to IgorMinar/angular that referenced this pull request Dec 19, 2018

feat(router): add predicate function mode for runGuardsAndResolvers (a…
…ngular#27682)

This option means guards and resolvers will ignore changes when a provided predicate function returns `false`. This supports use cases where an application needs to ignore some param updates but not others. For example, changing a sort param in the URL might need to be ignored, whereas changing the a `project` param might require re-run of guards and resolvers.

Related to angular#26861 angular#18253 angular#27464

PR Close angular#27682

FrederikSchlemmer added a commit to FrederikSchlemmer/angular that referenced this pull request Jan 3, 2019

feat(router): add pathParamsChange mode for runGuardsAndResolvers (an…
…gular#26861)

This option means guards and resolvers will ignore changes to optional
parameters such as query and matrix params. When the path or any path
params change, guards and resolvers will be run

Related to discussion in angular#18253
FW-560 #resolve

PR Close angular#26861

FrederikSchlemmer added a commit to FrederikSchlemmer/angular that referenced this pull request Jan 3, 2019

FrederikSchlemmer added a commit to FrederikSchlemmer/angular that referenced this pull request Jan 3, 2019

feat(router): add pathParamsOrQueryParamsChange mode for runGuardsAnd…
…Resolvers (angular#27464)

This option means guards and resolvers will ignore changes to matrix parameters. Guards and resolvers will be rerun when the path changes, when path parameters change, or when query parameters change.

The primary use case for such a mode is when updating the UI and getting the URL to be in sync with local changes. For example, if displaying a sortable table, changing the sort direction is often handled by the table itself. But you would want to update the URL to be in sync with what's being displayed to the user. As long as the table sort direction is stored as a matrix parameter, you can use this option to update the URL without causing the overhead of re-running guards and resolvers.

Related to angular#26861 angular#18253

PR Close angular#27464

ngfelixl added a commit to ngfelixl/angular that referenced this pull request Jan 28, 2019

ngfelixl added a commit to ngfelixl/angular that referenced this pull request Jan 28, 2019

feat(router): add pathParamsOrQueryParamsChange mode for runGuardsAnd…
…Resolvers (angular#27464)

This option means guards and resolvers will ignore changes to matrix parameters. Guards and resolvers will be rerun when the path changes, when path parameters change, or when query parameters change.

The primary use case for such a mode is when updating the UI and getting the URL to be in sync with local changes. For example, if displaying a sortable table, changing the sort direction is often handled by the table itself. But you would want to update the URL to be in sync with what's being displayed to the user. As long as the table sort direction is stored as a matrix parameter, you can use this option to update the URL without causing the overhead of re-running guards and resolvers.

Related to angular#26861 angular#18253

PR Close angular#27464

ngfelixl added a commit to ngfelixl/angular that referenced this pull request Jan 28, 2019

feat(router): add predicate function mode for runGuardsAndResolvers (a…
…ngular#27682)

This option means guards and resolvers will ignore changes when a provided predicate function returns `false`. This supports use cases where an application needs to ignore some param updates but not others. For example, changing a sort param in the URL might need to be ignored, whereas changing the a `project` param might require re-run of guards and resolvers.

Related to angular#26861 angular#18253 angular#27464

PR Close angular#27682
@simeyla

This comment has been minimized.

Copy link

simeyla commented Feb 25, 2019

@jasonaden Any reason why a never option wasn't added too for completeness?

I have child matrix parameters that I use ONLY to preselect an item from a dropdown. It isn't a component, and I don't want it to be a query parameter for readability.

 example.com/support/contact-us/technical    

So I get the dreaded Outlet is not activated error if defining a child route with no component.

As you can see I solve the problem of trying to resolve a component by using a custom runGuardsAndResolvers() => false. Had there been a **never** option - as somebody here suggested then I could have just used that.

The solution would have also been a lot more discoverable with never as an option too:

 {
        path: 'contact-us',
        component: ContactUsComponent,

        children: [
            {
                path: 'topics',
                pathMatch: 'full'
            },
            {
                path: ':category',
                runGuardsAndResolvers: () => false
            }
        ]
    }

https://stackoverflow.com/a/54875320/16940

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.