/ fm / liveswitch / PromiseBase
Class: PromiseBase<T>
fm.liveswitch.PromiseBase
Promise base properties/methods.
Type parameters
Name |
---|
T |
Hierarchy
Implements
Table of contents
Constructors
Methods
- castAndResolve
- doAll
- doAny
- fail
- getException
- getId
- getResult
- getState
- getTypeString
- process
- reject
- rejectAsync
- resolve
- resolveAsync
- setException
- setResult
- setState
- then
- all
- any
- delay
- rejectNow
- resolveNow
- wrapPromise
Constructors
constructor
+ new PromiseBase<T>(): PromiseBase<T>
Initializes a new instance of the [[fm.liveswitch.promiseBase]] class.
Type parameters:
Name |
---|
T |
Returns: PromiseBase<T>
Inherited from: Future
Defined in: Generated/TypeScript/fm.liveswitch/PromiseBase.ts:24
Methods
castAndResolve
▸ castAndResolve(result
: Object): boolean
Casts the result and resolves the promise. Will throw an exception if the cast fails.
Parameters:
Name | Type | Description |
---|---|---|
result |
Object | The result. |
Returns: boolean
Implementation of: IPromise
Defined in: Generated/TypeScript/fm.liveswitch/PromiseBase.ts:218
doAll
▸ Protected
doAll<R>(promises
: Future<R>[], counter
: AtomicInteger): void
Internal DoAll.
Type parameters:
Name | Type |
---|---|
R |
Object |
Parameters:
Name | Type |
---|---|
promises |
Future<R>[] |
counter |
AtomicInteger |
Returns: void
Defined in: Generated/TypeScript/fm.liveswitch/PromiseBase.ts:230
doAny
▸ Protected
doAny<R>(promises
: Future<R>[], resolveCount
: AtomicInteger, rejectCounter
: AtomicInteger): void
Internal DoAny.
Type parameters:
Name | Type |
---|---|
R |
Object |
Parameters:
Name | Type |
---|---|
promises |
Future<R>[] |
resolveCount |
AtomicInteger |
rejectCounter |
AtomicInteger |
Returns: void
Defined in: Generated/TypeScript/fm.liveswitch/PromiseBase.ts:261
fail
▸ Abstract
fail(rejectAction
: IAction1<Exception>): Future<T>
Parameters:
Name | Type |
---|---|
rejectAction |
IAction1<Exception> |
Returns: Future<T>
Inherited from: Future
Defined in: Generated/TypeScript/fm.liveswitch/Future.ts:7
getException
▸ getException(): Exception
Gets the exception if rejected.
Returns: Exception
Inherited from: Future
Defined in: Generated/TypeScript/fm.liveswitch/FutureBase.ts:35
getId
▸ getId(): string
Gets the identifier of this promise.
Returns: string
Defined in: Generated/TypeScript/fm.liveswitch/PromiseBase.ts:319
getResult
▸ getResult(): T
Gets the result if resolved.
Returns: T
Inherited from: Future
Defined in: Generated/TypeScript/fm.liveswitch/FutureBase.ts:47
getState
▸ getState(): FutureState
Gets the current state.
Returns: FutureState
Inherited from: Future
Defined in: Generated/TypeScript/fm.liveswitch/FutureBase.ts:59
getTypeString
▸ getTypeString(): string
Returns: string
Overrides: Future
Defined in: Generated/TypeScript/fm.liveswitch/PromiseBase.ts:10
process
▸ Protected
process(promise
: IPromise, resolve
: IAction1<T>, reject
: IAction1<Exception>): void
Processes the specified promise.
Parameters:
Name | Type | Description |
---|---|---|
promise |
IPromise | The promise. |
resolve |
IAction1<T> | The resolve. |
reject |
IAction1<Exception> | The reject. |
Returns: void
Defined in: Generated/TypeScript/fm.liveswitch/PromiseBase.ts:334
reject
▸ reject(exception
: Exception): boolean
Rejects the promise.
Parameters:
Name | Type | Description |
---|---|---|
exception |
Exception | The exception. |
Returns: boolean
Implementation of: IPromise
Defined in: Generated/TypeScript/fm.liveswitch/PromiseBase.ts:412
rejectAsync
▸ rejectAsync(exception
: Exception): Future<Object>
Rejects the promise asynchronously.
Parameters:
Name | Type | Description |
---|---|---|
exception |
Exception | The exception. |
Returns: Future<Object>
Defined in: Generated/TypeScript/fm.liveswitch/PromiseBase.ts:431
resolve
▸ resolve(result
: T): boolean
Resolves the promise.
Parameters:
Name | Type | Description |
---|---|---|
result |
T | The result. |
Returns: boolean
Defined in: Generated/TypeScript/fm.liveswitch/PromiseBase.ts:457
resolveAsync
▸ resolveAsync(result
: T): Future<Object>
Resolves the promise asynchronously.
Parameters:
Name | Type | Description |
---|---|---|
result |
T | The result. |
Returns: Future<Object>
Defined in: Generated/TypeScript/fm.liveswitch/PromiseBase.ts:476
setException
▸ Protected
setException(value
: Exception): void
Sets the exception if rejected.
Parameters:
Name | Type |
---|---|
value |
Exception |
Returns: void
Inherited from: Future
Defined in: Generated/TypeScript/fm.liveswitch/FutureBase.ts:71
setResult
▸ Protected
setResult(value
: T): void
Sets the result if resolved.
Parameters:
Name | Type |
---|---|
value |
T |
Returns: void
Inherited from: Future
Defined in: Generated/TypeScript/fm.liveswitch/FutureBase.ts:83
setState
▸ Protected
setState(value
: FutureState): void
Sets the current state.
Parameters:
Name | Type |
---|---|
value |
FutureState |
Returns: void
Inherited from: Future
Defined in: Generated/TypeScript/fm.liveswitch/FutureBase.ts:95
then
▸ Abstract
then<R>(resolve
: IAction1<T> | IFunction1<T, Future<R>>): Future<R>
Type parameters:
Name |
---|
R |
Parameters:
Name | Type |
---|---|
resolve |
IAction1<T> | IFunction1<T, Future<R>> |
Returns: Future<R>
Inherited from: Future
Defined in: Generated/TypeScript/fm.liveswitch/Future.ts:8
▸ Abstract
then<R>(resolve
: IAction1<T> | IFunction1<T, Future<R>>, reject
: IAction1<Exception>): Future<R>
Type parameters:
Name |
---|
R |
Parameters:
Name | Type |
---|---|
resolve |
IAction1<T> | IFunction1<T, Future<R>> |
reject |
IAction1<Exception> |
Returns: Future<R>
Inherited from: Future
Defined in: Generated/TypeScript/fm.liveswitch/Future.ts:9
all
▸ Static
all<R>(promises
: Future<R>[]): Future<R>
Returns a promise that resolves when all passed in promises resolve.
Type parameters:
Name | Type |
---|---|
R |
Object |
Parameters:
Name | Type | Description |
---|---|---|
promises |
Future<R>[] | The promises to check. |
Returns: Future<R>
Defined in: Generated/TypeScript/fm.liveswitch/PromiseBase.ts:55
any
▸ Static
any<R>(promises
: Future<R>[]): Future<R>
Returns a promise that resolves when any passed in promise resolves.
Type parameters:
Name | Type |
---|---|
R |
Object |
Parameters:
Name | Type | Description |
---|---|---|
promises |
Future<R>[] | The promises to check. |
Returns: Future<R>
Defined in: Generated/TypeScript/fm.liveswitch/PromiseBase.ts:75
delay
▸ Static
delay<R>(delayMs
: number): Future<R>
Create a promise that resolves afer a delay.
Type parameters:
Name | Type |
---|---|
R |
Object |
Parameters:
Name | Type |
---|---|
delayMs |
number |
Returns: Future<R>
Defined in: Generated/TypeScript/fm.liveswitch/PromiseBase.ts:96
rejectNow
▸ Static
rejectNow<R>(ex
: Exception): Future<R>
Creates a promise and rejects it immediately.
Type parameters:
Name | Type |
---|---|
R |
Object |
Parameters:
Name | Type | Description |
---|---|---|
ex |
Exception | The exception. |
Returns: Future<R>
Defined in: Generated/TypeScript/fm.liveswitch/PromiseBase.ts:123
resolveNow
▸ Static
resolveNow(): Future<Object>
Creates a promise and resolves it immediately using a null result value.
Returns: Future<Object>
Defined in: Generated/TypeScript/fm.liveswitch/PromiseBase.ts:138
▸ Static
resolveNow<R>(result
: R): Future<R>
Creates a promise and resolves it immediately using the given result value.
Type parameters:
Name | Type |
---|---|
R |
Object |
Parameters:
Name | Type | Description |
---|---|---|
result |
R | The result. |
Returns: Future<R>
Defined in: Generated/TypeScript/fm.liveswitch/PromiseBase.ts:146
wrapPromise
▸ Static
wrapPromise<R>(callback
: IFunction0<Future<R>>): Future<R>
Creates a promise and resolves it using the result from a callback function, or rejects it if an exception is thrown.
Type parameters:
Name | Type |
---|---|
R |
Object |
Parameters:
Name | Type | Description |
---|---|---|
callback |
IFunction0<Future<R>> | The callback function. |
Returns: Future<R>
Defined in: Generated/TypeScript/fm.liveswitch/PromiseBase.ts:166