From 6f6dd3c30939f00493f621467784f7b439254aea Mon Sep 17 00:00:00 2001 From: David Gardiner Date: Wed, 21 Jan 2015 12:02:18 +1030 Subject: [PATCH] Update EmberStates.Transition --- ember/ember.d.ts | 201 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 168 insertions(+), 33 deletions(-) diff --git a/ember/ember.d.ts b/ember/ember.d.ts index 682f796d6..2fd4ec555 100644 --- a/ember/ember.d.ts +++ b/ember/ember.d.ts @@ -11,15 +11,147 @@ declare var Handlebars: HandlebarsStatic; declare module EmberStates { interface Transition { - abort(): void; - addInitialStates(): void; - matchContextsToStates(contexts: any[]): void; - normalize(manager: Ember.StateManager, contexts: any[]): void; - removeUnchangedContexts(manager: Ember.StateManager): void; - retry(): void; - sendEvents(eventName: string, sendRecursiveArguments: boolean, isUnhandledPass: boolean): void; - sendRecursively(event: string, currentState: Ember.State, isUnhandledPass: boolean): void; targetName: string; + urlMethod: string; + intent: any; + params: {}; + pivotHandler: any; + resolveIndex: number; + handlerInfos: any; + resolvedModels: {}; + isActive: boolean; + state: any; + queryParams: {}; + queryParamsOnly: boolean; + + isTransition: boolean; + + /** + The Transition's internal promise. Calling `.then` on this property + is that same as calling `.then` on the Transition object itself, but + this property is exposed for when you want to pass around a + Transition's promise, but not the Transition object itself, since + Transition object can be externally `abort`ed, while the promise + cannot. + */ + promise: Ember.RSVP.Promise; + + /** + Custom state can be stored on a Transition's `data` object. + This can be useful for decorating a Transition within an earlier + hook and shared with a later hook. Properties set on `data` will + be copied to new transitions generated by calling `retry` on this + transition. + */ + data: any; + + /** + A standard promise hook that resolves if the transition + succeeds and rejects if it fails/redirects/aborts. + + Forwards to the internal `promise` property which you can + use in situations where you want to pass around a thennable, + but not the Transition itself. + + @arg {Function} onFulfilled + @arg {Function} onRejected + @arg {String} label optional string for labeling the promise. Useful for tooling. + @return {Promise} + */ + then(onFulfilled: Function, onRejected: Function, label?: string): Ember.RSVP.Promise; + + /** + Forwards to the internal `promise` property which you can + use in situations where you want to pass around a thennable, + but not the Transition itself. + + @method catch + @arg {Function} onRejection + @arg {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} + */ + catch(onRejection: Function, label?: string): Ember.RSVP.Promise; + + /** + Forwards to the internal `promise` property which you can + use in situations where you want to pass around a thennable, + but not the Transition itself. + + @method finally + @arg {Function} callback + @arg {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} + */ + finally(callback: Function, label?: string): Ember.RSVP.Promise; + + /** + Aborts the Transition. Note you can also implicitly abort a transition + by initiating another transition while a previous one is underway. + */ + abort(): EmberStates.Transition; + normalize(manager: Ember.StateManager, contexts: any[]): void; + + /** + Retries a previously-aborted transition (making sure to abort the + transition if it's still active). Returns a new transition that + represents the new attempt to transition. + */ + retry(): EmberStates.Transition; + + /** + Sets the URL-changing method to be employed at the end of a + successful transition. By default, a new Transition will just + use `updateURL`, but passing 'replace' to this method will + cause the URL to update using 'replaceWith' instead. Omitting + a parameter will disable the URL change, allowing for transitions + that don't update the URL at completion (this is also used for + handleURL, since the URL has already changed before the + transition took place). + + @arg {String} method the type of URL-changing method to use + at the end of a transition. Accepted values are 'replace', + falsy values, or any other non-falsy value (which is + interpreted as an updateURL transition). + + @return {Transition} this transition + */ + method(method: string): EmberStates.Transition; + + /** + Fires an event on the current list of resolved/resolving + handlers within this transition. Useful for firing events + on route hierarchies that haven't fully been entered yet. + + Note: This method is also aliased as `send` + + @arg {Boolean} [ignoreFailure=false] a boolean specifying whether unhandled events throw an error + @arg {String} name the name of the event to fire + */ + trigger(ignoreFailure:boolean, eventName: string); + /** + Fires an event on the current list of resolved/resolving + handlers within this transition. Useful for firing events + on route hierarchies that haven't fully been entered yet. + + Note: This method is also aliased as `send` + + @arg {String} name the name of the event to fire + */ + trigger(eventName: string); + + /** + Transitions are aborted and their promises rejected + when redirects occur; this method returns a promise + that will follow any redirects that occur and fulfill + with the value fulfilled by any redirecting transitions + that occur. + + @return {Promise} a promise that fulfills with the same + value that the final redirecting transition fulfills with + */ + followRedirects(): Ember.RSVP.Promise; } } @@ -1334,7 +1466,7 @@ declare module Ember { constructor(arr: any[]); static activate(): void; addArrayObserver(target: any, opts?: EnumerableConfigurationOptions): any[]; - addEnumerableObserver(target: any, opts: EnumerableConfigurationOptions): any[]; + addEnumerableObserver(target: any, opts: EnumerableConfigurationOptions): Enumerable; any(callback: Function, target?: any): boolean; anyBy(key: string, value?: string): boolean; arrayContentDidChange(startIdx: number, removeAmt: number, addAmt: number): any[]; @@ -1351,10 +1483,10 @@ declare module Ember { enumerableContentDidChange(removing: Enumerable, adding: number): any; enumerableContentDidChange(removing: number, adding: Enumerable): any; enumerableContentDidChange(removing: Enumerable, adding: Enumerable): any; - enumerableContentWillChange(removing: number, adding: number): any[]; - enumerableContentWillChange(removing: Enumerable, adding: number): any[]; - enumerableContentWillChange(removing: number, adding: Enumerable): any[]; - enumerableContentWillChange(removing: Enumerable, adding: Enumerable): any[]; + enumerableContentWillChange(removing: number, adding: number): Enumerable; + enumerableContentWillChange(removing: Enumerable, adding: number): Enumerable; + enumerableContentWillChange(removing: number, adding: Enumerable): Enumerable; + enumerableContentWillChange(removing: Enumerable, adding: Enumerable): Enumerable; every(callback: Function, target?: any): boolean; everyBy(key: string, value?: string): boolean; everyProperty(key: string, value?: any): boolean; @@ -1381,7 +1513,7 @@ declare module Ember { rejectBy(key: string, value?: string): any[]; removeArrayObserver(target: any, opts: EnumerableConfigurationOptions): any[]; removeAt(start: number, len: number): any; - removeEnumerableObserver(target: any, opts: EnumerableConfigurationOptions): any[]; + removeEnumerableObserver(target: any, opts: EnumerableConfigurationOptions): Enumerable; replace(idx: number, amt: number, objects: any[]): any; reverseObjects(): any[]; setEach(key: string, value?: any): any; @@ -1390,10 +1522,10 @@ declare module Ember { slice(beginIndex?: number, endIndex?: number): any[]; some(callback: Function, target?: any): boolean; toArray(): any[]; - uniq(): any[]; + uniq(): Enumerable; unshiftObject(object: any): any; unshiftObjects(objects: any[]): any[]; - without(value: any): any[]; + without(value: any): Enumerable; '[]': any[]; '@each': EachProxy; Boolean: boolean; @@ -1402,30 +1534,30 @@ declare module Ember { lastObject: any; length: number; addObject(object: any): any; - addObjects(objects: Enumerable): any[]; + addObjects(objects: Enumerable): MutableEnumberable; removeObject(object: any): any; - removeObjects(objects: Enumerable): any[]; + removeObjects(objects: Enumerable): MutableEnumberable; addObserver: ModifyObserver; - beginPropertyChanges(): any[]; + beginPropertyChanges(): Observable; cacheFor(keyName: string): any; decrementProperty(keyName: string, decrement?: number): number; - endPropertyChanges(): any[]; + endPropertyChanges(): Observable; get(keyName: string): any; getProperties(...args: string[]): {}; getProperties(keys: string[]): {}; getWithDefault(keyName: string, defaultValue: any): any; hasObserverFor(key: string): boolean; incrementProperty(keyName: string, increment?: number): number; - notifyPropertyChange(keyName: string): any[]; - propertyDidChange(keyName: string): any[]; - propertyWillChange(keyName: string): any[]; - removeObserver(key: string, target: any, method: string): Observable; - removeObserver(key: string, target: any, method: Function): Observable; - set(keyName: string, value: any): any[]; - setProperties(hash: {}): any[]; + notifyPropertyChange(keyName: string): Observable; + propertyDidChange(keyName: string): Observable; + propertyWillChange(keyName: string): Observable; + removeObserver(key: string, target: any, method: string): void; + removeObserver(key: string, target: any, method: Function): void; + set(keyName: string, value: any): Observable; + setProperties(hash: {}): Observable; toggleProperty(keyName: string): any; - copy(deep: boolean): any[]; - frozenCopy(): any[]; + copy(deep: boolean): Copyable; + frozenCopy(): Copyable; } class NoneLocation extends Object { static detect(obj: any): boolean; @@ -1549,11 +1681,14 @@ declare module Ember { notifyPropertyChange(keyName: string): Observable; propertyDidChange(keyName: string): Observable; propertyWillChange(keyName: string): Observable; - removeObserver(key: string, target: {}, method: string): Observable; - removeObserver(key: string, target: {}, method: Function): Observable; + removeObserver(key: string, target: {}, method: string): void; + removeObserver(key: string, target: {}, method: Function): void; set(keyName: string, value: any): Observable; setProperties(hash: {}): Observable; - toggleProperty(keyName: string): any; + /** + Set the value of a boolean property to the opposite of its current value. + */ + toggleProperty(keyName: string): boolean; } class OrderedSet { add(obj: any): void; @@ -1623,7 +1758,7 @@ declare module Ember { serialize(model: {}, params: string[]): string; setupController(controller: Controller, model: {}): void; // ReSharper disable once InconsistentNaming - transitionTo(name: string, ...object: any[]): void; + transitionTo(name: string, ...object: any[]): EmberStates.Transition; actions: ActionsHash; } class Router extends Object {