Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Ability to manually trigger all resolvers on route change #31843

@DanKing123

Description

@DanKing123

I have seen quite a few tickets related to this on github, and quite a few posts on this topic involving various workarounds elsewhere on the internet, e.g. on Stack Overflow, but there still doesn't seem to be a proper, simple solution for this included within the framework.

This is my use case:

  1. I have 2 routes with components - A & B - which share a common parent root (C).
  2. I have a resolver configured on C. A & B both share the data from this resolver
  3. In component A, I am performing a server update of the shared data, before navigating to route B.
  4. When performing this navigation, I want to force the resolver on C to fire again, so that B can see the latest version of the data that has just been modified by A.

Just to be clear:

  1. I do not want the resolver on C to fire every time I navigate between child routes of C, and I definitely don't want all my other resolvers firing every time I navigate between child routes. So onSameUrlNavigation is too course a solution for this use case.
  2. I want to be able to force all the resolvers to fire programatically, at the point of navigation, in specific situations as required - i.e. when I have just performed a server update and the route state has not yet been refreshed.

So I am looking for a parameter, or configuration option, that can be passed to Router.navigate() or navigateByUrl() that will force all the resolvers (and probably the guards) in the target route (hierarchy) to be re-executed.

E.g. something like the reload: true option provided in the AngularJS UI router, see here: https://ui-router.github.io/ng1/docs/latest/interfaces/transition.transitionoptions.html#reload - although I believe that also causes all the components to be destroyed and re-created, which is probably not necessary in this case.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions