MyGit

1.0.0

angular-ui/ui-router

版本发布时间: 2017-06-11 05:51:07

angular-ui/ui-router最新发布版本:1.1.1(2024-07-15 19:46:04)

1.0.0-rc.1...1.0.0 (2017-04-30)

NOTICE: The npm package is renamed from angular-ui-router to @uirouter/angularjs

Bug Fixes

Features

UI-Router for AngularJS version 1.0.0 updates ui-router-core@3.1.0 to @uirouter/core@5.0.1. Please keep reading to see if the breaking changes from core between 3.1.0 and 5.0.1 affect you.

@uirouter/core changes 3.1.0...5.0.0 (2017-04-30)

Bug Fixes

Features

BREAKING CHANGES

TransitionHook: Transition hooks no longer expose the internal State object (now named StateObject)

Before:

import { State } from "ui-router-core";
const match = { to: (state: State) => state.data.auth };
transitionsvc.onEnter(match, (trans: Transition, state: State) => {
  // state is the internal State object
  if (state.includes["foo"]) { // internal ui-router API
    return false;
  }
}

Now:

import { StateDeclaration } from "ui-router-core";
const match = { to: (state: StateDeclaration) => state.data.auth };
transitionsvc.onEnter(match, (trans: Transition, state: StateDeclaration) => {
  // state === the state object you registered
  // Access internal ui-router API using $$state()
  if (state.$$state().includes["foo"]) {
    return false;
  }
}

Motivation:

The State object (now named StateObject) is an internal API and should not be exposed via any public APIs. If you depend on the internal APIs, you can still access the internal object by calling state.$$state().

BC Likelihood

How likely is this BC to affect me?

Medium: You will likely be affected you 1) have transition hooks, 2) are using typescript and/or 3) use the internal ui-router State API.

BC Severity

How severe is this BC?

Low: Access to the internal api is still available using $$state().

StateObject: Renamed internal API State object to StateObject

Before:

import {State} from "ui-router-core";
import {StateObject} from "ui-router-core";

Motivation:

We'd like to use the State name/symbol as a public API.
It will likely be an ES7/TS decorator for ES6/TS state definition classes, i.e:

@State("foo")
export class FooState implements StateDeclaration {
  url = "/foo";
  component = FooComponent;

  @Resolve({ deps: [FooService] })
  fooData(fooService) {
    return fooService.getFoos();
  }
}

BC Likelihood

How likely is this to affect me?

Low: This only affects code that imports the internal API symbol State. You will likely be affected you 1) import that symbol, 2) are using typescript and 3) explicitly typed a variable such as let internalStateObject = state.$$state();

BC Severity

How severe is this change?

Low: Find all places where State is imported and rename to StateObject

Transition: All Transition errors are now wrapped in a Rejection object.

Before:

Previously, if a transition hook returned a rejected promise:

.onStart({}, () => Promise.reject('reject transition'));

In onError or transtion.promise.catch(), the raw rejection was returned:

.onError({}, (trans, err) => err === 'reject transition')

Now:

Now, the error is wrapped in a Rejection object.

.onError({}, (trans, err) =>
    err instanceof Rejection && err.detail === 'reject transition')
.onError({}, (trans, err) => {
  err.type === RejectType.ABORTED === 3
});

Motivation:

Errors thrown from a hook and rejection values returned from a hook can now be processed in the same way.

BC Likelihood

How likely is this to affect me?

Medium: apps which have onError handlers for rejected values

BC Severity

How severe is this change?

Low: Find all error handlers (or .catch/.then chains) that do not understand Rejection. Add err.detail processing.

onBefore: onBefore hooks are now run asynchronously like all the other hooks.

Old behavior

Previously, the onBefore hooks were run in the same stackframe as transitionTo. If they threw an error, it could be caught using try/catch.

transitionService.onBefore({ to: 'foo' }), () => { throw new Error('doh'); });
try {
  stateService.go('foo');
} catch (error) {
  // handle error
}

New behavior

Now, onBefore hooks are processed asynchronously. To handle errors, use any of the async error handling paradigms:

Motivation

Why introduce a BC?

BC Liklihood

How likely is this to affect my app?

Very Low: Apps that registered onBefore hooks and depend on synchronous execution are affected.

BC Severity

How severe is this BC?

Low: Switch to asynchronous handling, such as chaining off the transition promise

defaultErrorHandler: ABORTED transitions do not invoke the defaultErrorHandler

Returning false from a transition hook will abort the transition.

Old behavior

Previously, this case was considered an error and was logged by defaultErrorHandler. After your feedback, we agree that this is not typically an error.

New behavior

Now, aborted transitions do not trigger the defaultErrorHandler

Motivation:

Why introduce a BC?

Most users do not consider ABORT to be an error. The default error handler should match this assumption.

BC liklihood

How likely am I to be affected?

Low: Most users do not consider ABORT to be an error. For most users this will not be a BC.

BC severity

How severe is this BC?

Low: Users who want to handle all transition rejections can register a .onError handler and filter/process accordingly.

globals: This change will likely only affect a small subset of typescript users and probably only those using ui-router-ng2.

If you're injecting the Globals class somewhere, e.g.:

@Injectable()
class MyService {
  _globals: UIRouterGlobals;
  constructor(globals: Globals) {
    this._globals = <UIRouterGlobals> globals;
  }
}

you should now inject UIRouterGlobals, e.g.:

@Injectable()
class MyService {
  constructor(public globals: UIRouterGlobals) { }
}

Likewise, if you were casting the UIRouter.globals object as a UIRouterGlobals, it is no longer necessary:

function myHook(trans: Transition) {
  let globals: UIRouterGlobals = trans.router.globals; // cast is no longer necessary
}

Closes https://github.com/ui-router/core/issues/31

相关地址:原始地址 下载(tar) 下载(zip)

查看:2017-06-11发行的版本