Skip to content

1.0 redirect: certain resolves are not reloaded, even if reloadState is set #2539

Closed
@christopherthielen

Description

@christopherthielen

If a transition is redirected, and the target state's reloadState is set to an (internal) state object, the resolves for that state should reload because the state is exited/entered.

http://plnkr.co/edit/7Dxx3hGiTeObMGWFVS7D?p=preview

However, we retain already-resolved-data during redirects to avoid double-fetching resolves. This happens for instance if a hook depends on a resolve, and then redirects to a default substate. We do not want to re-fetch the resolve, so it is provided to the redirected transition pre-resolved.

// If the current transition has already resolved any resolvables which are also in the redirected "to path", then
// add those resolvables to the redirected transition. Allows you to define a resolve at a parent level, wait for
// the resolve, then redirect to a child state based on the result, and not have to re-fetch the resolve.
let redirectedPath = this.treeChanges().to;
let matching: Node[] = Node.matching(redirectTo.treeChanges().to, redirectedPath);
const includeResolve = (resolve, key) => ['$stateParams', '$transition$'].indexOf(key) === -1;
matching.forEach((node, idx) => extend(node.resolves, filter(redirectedPath[idx].resolves, includeResolve)));

This logic in Transition.redirect() should filter out "matching" states when the options.redirectState .includes() the state.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions