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): take only the first emitted value of every resolver #44573
Conversation
I certainly don't disagree that this likely should have been written this way in the first place. That said, this change is at the very least a breaking change and will need to wait until the next major version. You'll need to add a BREAKING CHANGES
footer note to the commit message.
Depending on internal test results, we'll have to determine if this is worth the migration effort. I imagine there should be little to no failures so we should be able to do this, but you never really know until the test results come back.
Also, I think you will need to update the documentation. There are two places that mention that observables must complete in the tutorial. While those mention guards rather than resolvers, I believe that documentation is incorrect or outdated since I see observable.pipe(first())
in the guard execution code. I thought there was also somewhere that mentions this for resolvers, but I can't find it. Maybe I was thinking of this:
angular/aio/content/guide/router-tutorial-toh.md
Line 2444 in 8ebc946
1. Returning an empty `Observable` in at least one resolver cancels navigation. |
@@ -23,6 +23,7 @@ describe('resolveData operator', () => { | |||
{provide: 'resolveTwo', useValue: (a: any, b: any) => of(2)}, | |||
{provide: 'resolveFour', useValue: (a: any, b: any) => 4}, | |||
{provide: 'resolveEmpty', useValue: (a: any, b: any) => EMPTY}, | |||
{provide: 'resolveZero', useValue: (a: any, b: any) => interval()}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Given that this doesn't really resolve 0, but is rather an interval, I think this should be renamed.
@dimakuba Can you also explain the rationale behind this change? What does this help or solve? Is it just for consistency with guards? Because the |
Yes, you're right, this change is mostly for consistency with guards to take only the first emitted value and complete the |
@dimakuba That's fair and I think this is worth making consistent. Action items for merging:
|
@dimakuba The main branch is now targeting v14 so we can land this change when the action items are addressed. |
4780ba6
to
a14de51
Compare
|
@atscott the only last point left to resolve |
a14de51
to
97f9635
Compare
g3 cleanup is finished. green TGP |
… to make it consistent with guards The router used to wait for the resolvers to complete and take the last value. The changes here take only the first emitted value of every resolver and proceed the navigation. This matches how other guards work in the `Router` code. Resolves angular#44643 BREAKING CHANGE: Previously, resolvers were waiting to be completed before proceeding with the navigation and the Router would take the last value emitted from the resolver. The router now takes only the first emitted value by the resolvers and then proceeds with navigation. This is now consistent with `Observables` returned by other guards: only the first value is used.
97f9635
to
389d926
Compare
This PR was merged into the repository by commit c967976. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
… to make it consistent with guards (angular#44573) The router used to wait for the resolvers to complete and take the last value. The changes here take only the first emitted value of every resolver and proceed the navigation. This matches how other guards work in the `Router` code. Resolves angular#44643 BREAKING CHANGE: Previously, resolvers were waiting to be completed before proceeding with the navigation and the Router would take the last value emitted from the resolver. The router now takes only the first emitted value by the resolvers and then proceeds with navigation. This is now consistent with `Observables` returned by other guards: only the first value is used. PR Close angular#44573
The router now waits for the resolvers to complete even they emitted at
least one value. The changes make it possible to take only the first
emitted value of every resolver and proceed the navigation.