Skip to content

Commit

Permalink
feat(Transition): Expose the transition's TargetState as targetState()
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherthielen committed Aug 31, 2016
1 parent 5d42d79 commit f06f6b6
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/transition/transition.ts
Expand Up @@ -47,7 +47,6 @@ export class Transition implements IHookRegistry {
static diToken = Transition;

$id: number;
success: boolean;

/**
* A reference to the [[UIRouter]] instance
Expand All @@ -58,18 +57,26 @@ export class Transition implements IHookRegistry {

/** @hidden */
private _deferred = services.$q.defer();
/** @hidden */
private _error: any;
/**
* This promise is resolved or rejected based on the outcome of the Transition.
*
* When the transition is successful, the promise is resolved
* When the transition is unsuccessful, the promise is rejected with the [[TransitionRejection]] or javascript error
*/
promise: Promise<any> = this._deferred.promise;
/**
* A boolean which indicates if the transition was successful
*
* After a successful transition, this value is set to true.
* After a failed transition, this value is set to false.
*/
success: boolean;
/** @hidden */
private _error: any;

private _options: TransitionOptions;
private _treeChanges: TreeChanges;
private _targetState: TargetState;

/** @inheritdoc */
onBefore (matchCriteria: HookMatchCriteria, callback: TransitionHookFn, options?: HookRegOptions) : Function { throw ""; };
Expand Down Expand Up @@ -102,6 +109,8 @@ export class Transition implements IHookRegistry {
*/
constructor(fromPath: PathNode[], targetState: TargetState, router: UIRouter) {
this.router = router;
this._targetState = targetState;

if (!targetState.valid()) {
throw new Error(targetState.error());
}
Expand Down Expand Up @@ -155,6 +164,17 @@ export class Transition implements IHookRegistry {
return this.$to().self;
}

/**
* Gets the Target State
*
* A transition's [[TargetState]] encapsulates the [[to]] state, the [[params]], and the [[options]].
*
* @returns the [[TargetState]] of this Transition
*/
targetState() {
return this._targetState;
}

/**
* Determines whether two transitions are equivalent.
*/
Expand Down

0 comments on commit f06f6b6

Please sign in to comment.