Skip to content

Update reference doc for router guards and resolvers#38079

Closed
jbogarthyde wants to merge 1 commit into
angular:masterfrom
jbogarthyde:jb-apidoc-guards
Closed

Update reference doc for router guards and resolvers#38079
jbogarthyde wants to merge 1 commit into
angular:masterfrom
jbogarthyde:jb-apidoc-guards

Conversation

@jbogarthyde

@jbogarthyde jbogarthyde commented Jul 15, 2020

Copy link
Copy Markdown
Contributor

Complete and clarify descriptions and examples of the guard and resolver functions in Router API documentation.

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Examples are not described and the usage descriptions are incomplete

Issue Number: N/A

What is the new behavior?

Corrects language style and adds descriptions of examples

Does this PR introduce a breaking change?

  • Yes
  • No

@jbogarthyde jbogarthyde added type: bug/fix comp: docs action: review The PR is still awaiting reviews from at least one requested reviewer effort1: hours freq1: low target: patch This PR is targeted for the next patch release risk: low router: guards/resolvers labels Jul 15, 2020
@jbogarthyde jbogarthyde requested a review from atscott July 15, 2020 16:49
@jbogarthyde jbogarthyde self-assigned this Jul 15, 2020
@ngbot ngbot Bot modified the milestone: Backlog Jul 15, 2020
@atscott atscott added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jul 15, 2020
@mary-poppins

Copy link
Copy Markdown

You can preview 4a44f2d at https://pr38079-4a44f2d.ngbuilds.io/.

@jbogarthyde jbogarthyde changed the title docs: update reference doc for router guards and resolvers Update reference doc for router guards and resolvers Jul 15, 2020
Comment thread packages/router/src/interfaces.ts Outdated
Comment on lines 294 to 295

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* When both guard functions and resolvers are specified, the resolvers are not executed until
* all guards for a route tree have run and succeeded.
* When both guards and resolvers are specified, the resolvers are not executed until
* all guards have run and succeeded.

Comment thread packages/router/src/interfaces.ts Outdated
Comment on lines 296 to 299

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually confusing, since we would only run the guards/resolvers for the tree being activated. Maybe use a concrete example instead, something like:

{
  path: 'base'
  canActivate: [BaseGuard],
  resolve: {data: BaseDataResolver}
  children: [
    {
      path: 'child',
      guards: [ChildGuard],
      resolve: {childData: ChildDataResolver}
    } 
  ]
}

Order of execution is BaseGuard, ChildGuard, BaseDataResolver, ChildDataResolver

Here's an example: https://stackblitz.com/edit/angular-ivy-router-base-rgemdd?file=src%2Fapp%2Fapp.module.ts

@jbogarthyde jbogarthyde removed the action: merge The PR is ready for merge by the caretaker label Jul 15, 2020
@mary-poppins

Copy link
Copy Markdown

You can preview 5c76197 at https://pr38079-5c76197.ngbuilds.io/.

@atscott atscott added the action: merge The PR is ready for merge by the caretaker label Jul 15, 2020
Comment thread packages/router/src/interfaces.ts Outdated
@atscott

atscott commented Jul 15, 2020

Copy link
Copy Markdown
Contributor

The clarification in the docs here resolves #37625

Complete and clarify descriptions and example of the guard and resolver functions in Router API documentation.
@mary-poppins

Copy link
Copy Markdown

You can preview 910e49f at https://pr38079-910e49f.ngbuilds.io/.

@mary-poppins

Copy link
Copy Markdown

You can preview 034b59e at https://pr38079-034b59e.ngbuilds.io/.

@jbogarthyde

Copy link
Copy Markdown
Contributor Author

Doc only -- should not need g3

AndrewKushnir pushed a commit that referenced this pull request Jul 15, 2020
Complete and clarify descriptions and example of the guard and resolver functions in Router API documentation.

PR Close #38079
@jbogarthyde jbogarthyde deleted the jb-apidoc-guards branch July 20, 2020 15:29
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Aug 20, 2020
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
…8079)

Complete and clarify descriptions and example of the guard and resolver functions in Router API documentation.

PR Close angular#38079
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker cla: yes effort1: hours freq1: low risk: low router: guards/resolvers target: patch This PR is targeted for the next patch release type: bug/fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Resolve not invoked with lazy-loaded module using loadChildren as promise

4 participants