Skip to content
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

1.0 during redirect: unable to specify reload option #2537

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

1.0 during redirect: unable to specify reload option #2537

christopherthielen opened this issue Feb 8, 2016 · 0 comments

Comments

@christopherthielen
Copy link
Contributor

This doesn't work:

$transitions.onStart({ to: 'foo' }, ($state, $transition$) => {
  let options = $transition$.options();
  if (!options.reload) {
    return $state.target($transition$.to(), $transition$.params("to"), extend({}, options, { reload: true }));
  }
});

because reload: true is never processed for a redirection.


We process reload option in state.transitionTo:

// If we're reloading, find the state object to reload from
if (isObject(options.reload) && !(<any>options.reload).name)
throw new Error('Invalid reload state object');
options.reloadState = options.reload === true ? this.$current.path[0] : this.stateRegistry.matcher.find(<any> options.reload, options.relative);
if (options.reload && !options.reloadState)
throw new Error(`No such reload state '${(isString(options.reload) ? options.reload : (<any>options.reload).name)}'`);

    // If we're reloading, find the state object to reload from
    if (isObject(options.reload) && !(<any>options.reload).name)
      throw new Error('Invalid reload state object');
    options.reloadState = options.reload === true ? this.$current.path[0] : this.stateRegistry.matcher.find(<any> options.reload, options.relative);

    if (options.reload && !options.reloadState)
      throw new Error(`No such reload state '${(isString(options.reload) ? options.reload : (<any>options.reload).name)}'`);

... but when we process a redirected transition, we do not call transitionTo. instead, we run the transition directly:

if (error.type === RejectType.SUPERSEDED && error.redirected && error.detail instanceof TargetState) {
return this._redirectMgr(transition.redirect(error.detail)).runTransition();
}

We should process the "reload" logic elsewhere; possibly in $state.target() factory function.

Note: this.$current.path[0] is the implicit root state so we can get it from stateRegistry, not $current.

@christopherthielen christopherthielen added this to the 1.0.0-beta milestone 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