Skip to content

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

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

Closed
christopherthielen opened this issue Feb 8, 2016 · 0 comments

Comments

@christopherthielen
Copy link
Contributor

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.

@christopherthielen christopherthielen added this to the 1.0.0-beta milestone Feb 8, 2016
@christopherthielen christopherthielen changed the title 1.0 redirect: resolves are not reloaded, even if reloadState is set 1.0 redirect: certain resolves are not reloaded, even if reloadState is set Feb 8, 2016
@christopherthielen christopherthielen modified the milestones: 1.0.0-beta, 1.0.0-alpha.1 Mar 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant