Skip to content

Resolve cancel behavior should be documented clearly #23659

Closed

Description

@ienzam

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[x] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
[ ] Other... Please describe:

Current behavior

I am trying to figure out how to cancel a navigation request from a Resolve. For example, if the resolver is requesting data from server and server returns an error, I want to cancel the navigation. Looking at the documentations https://next.angular.io/api/router/Routes, https://next.angular.io/api/router/Resolve and https://next.angular.io/tutorial/toh-pt5, I couldn't find any solution to that.

After searching a lot, I found out that returning empty observable cancels the navigation. But it is not documented anywhere.

Expected behavior

The behavior of Resolve should be documented. It should clearly state what happens on error and how to cancel navigation.

Minimal reproduction of the problem with instructions

https://stackblitz.com/edit/angular-gitter-r8sesk

  • Check the 'okay' router link. Resolver for the url returns a Observable.of() value, so navigation to that url works as expected.
  • Check the 'error' router link. Resolver for the url returns a Observable.empty() value, so navigation to that url does not work.

What is the motivation / use case for changing the behavior?

Make it clearer for users.

Environment


Angular version: v6.0.0-rc.6


Browser:
- [x] Chrome (desktop) version XX
- [x] Chrome (Android) version XX
- [x] Chrome (iOS) version XX
- [x] Firefox version XX
- [x] Safari (desktop) version XX
- [x] Safari (iOS) version XX
- [x] IE version XX
- [x] Edge version XX

Activity

  1. djleonskennedy commented on May 3, 2018

    @djleonskennedy

    @ienzam Guards might help you

  2. added this to the needsTriage milestone on May 3, 2018
  3. ienzam commented on May 7, 2018

    @ienzam
    Author

    @djleonskennedy Guards have different purpose than resolve, and also I think resolve happens after guard.

  4. modified the milestones: needsTriage, Backlog on May 8, 2018
  5. brandonroberts commented on Sep 26, 2018

    @brandonroberts
    Contributor

    Fixed via #20023

  6. angular-automatic-lock-bot commented on Sep 14, 2019

    @angular-automatic-lock-bot

    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.

  7. locked and limited conversation to collaborators on Sep 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions