X Tutup
The Wayback Machine - https://web.archive.org/web/20220611180013/https://github.com/angular/angular/pull/44189
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 type properties to all router events #44189

Closed
wants to merge 3 commits into from

Conversation

clydin
Copy link
Member

@clydin clydin commented Nov 16, 2021

All router events now have a type property with a string name identifying the specific type of the event. The type property can be used to perform TypeScript type narrowing using an if statement, switch statement, or similar. This removes the need to perform instanceof checks but still allows them if preferred. An instanceof check requires the use of the event class value which may not be available or preferred in certain situations.

@google-cla google-cla bot added the cla: yes label Nov 16, 2021
packages/router/src/events.ts Outdated Show resolved Hide resolved
@ngbot ngbot bot added this to the Backlog milestone Nov 18, 2021
@atscott atscott added the target: minor label Apr 1, 2022
@clydin clydin force-pushed the router/event-types branch 2 times, most recently from 5427cf2 to 1b177dc Compare Apr 2, 2022
@clydin clydin force-pushed the router/event-types branch 4 times, most recently from d26e936 to 30c8187 Compare Apr 11, 2022
@Smrtnyk
Copy link

@Smrtnyk Smrtnyk commented Apr 20, 2022

Tnx a lot for this PR, will help us a lot in our use case

clydin added 2 commits Apr 21, 2022
All router events now have a `type` property with a string name identifying the specific type of the event.
The `type` property can be used to perform TypeScript type narrowing using an `if` statement, `switch`
statement, or similar. This removes the need to perform `instanceof` checks but still allows them if
preferred. An `instanceof` check requires the use of the event class value which may not be available
or preferred in certain situations.
The Router's `enableTracing` option is also now guarded with the `ngDevMode` flag which combined with
the use of a new `stringifyEvent` function allows the tree-shaking of the string generation code for
each router event class. However, the original `toString` class methods are still present to prevent
a potential breaking change. As a result, full benefits of the tree-shaking potential will not be realized
until they are removed.
@atscott atscott marked this pull request as ready for review May 2, 2022
@atscott atscott removed this from the Backlog milestone May 2, 2022
@atscott atscott added this to the v14-candidates milestone May 2, 2022
atscott
atscott previously approved these changes May 2, 2022
Copy link
Contributor

@atscott atscott left a comment

reviewed-for: public-api, fw-router

@dylhunn
Copy link
Contributor

@dylhunn dylhunn commented May 2, 2022

@clydin @atscott Is this something we'd like to merge for 14? If so, it is mergeable, or is cleanup needed? Thanks!

@atscott
Copy link
Contributor

@atscott atscott commented May 2, 2022

@dylhunn I optimistically targeted v14 today. This should be straightforward to review and land. g3 cleanup was already done by @clydin

atscott
atscott approved these changes May 2, 2022
Copy link
Contributor

@atscott atscott left a comment

reviewed-for: public-api, fw-router

dylhunn
dylhunn approved these changes May 2, 2022
Copy link
Contributor

@dylhunn dylhunn left a comment

reviewed-for: public-api

@dylhunn
Copy link
Contributor

@dylhunn dylhunn commented May 2, 2022

Awesome, presubmit looks green. Lmk when you are ready for merge.

@atscott atscott added action: merge action: merge-assistance labels May 2, 2022
@ngbot
Copy link

@ngbot ngbot bot commented May 2, 2022

I see that you just added the action: merge label, but the following checks are still failing:
    failure status "pullapprove" is failing
    pending 2 pending code reviews

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.

@atscott
Copy link
Contributor

@atscott atscott commented May 2, 2022

merge assistance: pullapprove is down. This has all necessary approvals

@atscott atscott added action: global presubmit and removed action: merge action: merge-assistance labels May 3, 2022
@atscott atscott removed this from the v14-candidates milestone May 3, 2022
@atscott atscott added this to the v14.1-candidates milestone May 3, 2022
@atscott
Copy link
Contributor

@atscott atscott commented May 3, 2022

Moving to v14.1 candidates. Global presubmit revealed a lot more work needs to be done to resolve failures there. We'll also need to make a decision on whether this needs to be considered breaking based on how many failures there were.

@atscott atscott added action: merge action: merge-assistance and removed action: global presubmit labels May 4, 2022
@atscott
Copy link
Contributor

@atscott atscott commented May 4, 2022

merge assistance: There is one outstanding fix in g3 that needs approval from a team in the European timezone. Please merge this at the very end and maybe wait until tomorrow to sync it to g3.

@atscott atscott removed the action: merge-assistance label May 4, 2022
@atscott
Copy link
Contributor

@atscott atscott commented May 4, 2022

Removing merge assistance. The CL is now submitted. This is good to go.

@atscott atscott added the action: merge-assistance label May 4, 2022
@atscott atscott removed request for alxhub and jessicajaniuk May 4, 2022
@atscott atscott removed the action: merge-assistance label May 4, 2022
@atscott atscott removed this from the v14.1-candidates milestone May 4, 2022
@atscott atscott added this to the v14-candidates milestone May 4, 2022
@dylhunn
Copy link
Contributor

@dylhunn dylhunn commented May 4, 2022

This PR was merged into the repository by commit 41e2a68.

@dylhunn dylhunn closed this in 41e2a68 May 4, 2022
@clydin clydin deleted the router/event-types branch May 5, 2022
@angular-automatic-lock-bot
Copy link

@angular-automatic-lock-bot angular-automatic-lock-bot bot commented Jun 5, 2022

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 Jun 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge cla: yes comp: router target: minor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants
X Tutup