Class Promise<T>
A promise.
Implements
Inherited Members
Namespace: FM.LiveSwitch
Assembly: FM.LiveSwitch.dll
Syntax
public class Promise<T> : PromiseBase<T>, IPromise where T : class
Type Parameters
Name | Description |
---|---|
T | The type of the result. |
Constructors
Promise()
Creates a new promise.
Declaration
public Promise()
Promise(Action2<Action1<T>, Action1<Exception>>)
Creates a promise with a resolve callback and a reject callback.
Declaration
public Promise(Action2<Action1<T>, Action1<Exception>> callback)
Parameters
Type | Name | Description |
---|---|---|
Action2<Action1<T>, Action1<System.Exception>> | callback |
Methods
Fail(Action1<Exception>)
Appends a handler to be executed when the promise is rejected.
Declaration
public override Future<T> Fail(Action1<Exception> rejectAction)
Parameters
Type | Name | Description |
---|---|---|
Action1<System.Exception> | rejectAction | The reject action. |
Returns
Type | Description |
---|---|
Future<T> |
Overrides
Fail(Function1<Exception, Future<T>>)
Appends a handler to be executed when the promise is rejected.
Declaration
public override Future<T> Fail(Function1<Exception, Future<T>> rejectFunction)
Parameters
Type | Name | Description |
---|---|---|
Function1<System.Exception, Future<T>> | rejectFunction | The reject function. |
Returns
Type | Description |
---|---|
Future<T> |
Overrides
Then(Action1<T>)
Appends a handler to be executed when the promise is resolved.
Declaration
public override Future<T> Then(Action1<T> resolveAction)
Parameters
Type | Name | Description |
---|---|---|
Action1<T> | resolveAction | The resolve action. |
Returns
Type | Description |
---|---|
Future<T> |
Overrides
Then(Action1<T>, Action1<Exception>)
Appends handlers to be executed when the promise is resolved or rejected.
Declaration
public override Future<T> Then(Action1<T> resolveAction, Action1<Exception> rejectAction)
Parameters
Type | Name | Description |
---|---|---|
Action1<T> | resolveAction | The resolve action. |
Action1<System.Exception> | rejectAction | The reject action. |
Returns
Type | Description |
---|---|
Future<T> |
Overrides
Then<R>(Function1<T, Future<R>>)
Appends a handler to be executed when the promise is resolved.
Declaration
public override Future<R> Then<R>(Function1<T, Future<R>> resolveFunction)
where R : class
Parameters
Type | Name | Description |
---|---|---|
Function1<T, Future<R>> | resolveFunction | The resolve function. |
Returns
Type | Description |
---|---|
Future<R> |
Type Parameters
Name | Description |
---|---|
R |
Overrides
Then<R>(Function1<T, Future<R>>, Action1<Exception>)
Appends handlers to be executed when the promise is resolved or rejected.
Declaration
public override Future<R> Then<R>(Function1<T, Future<R>> resolveFunction, Action1<Exception> rejectAction)
where R : class
Parameters
Type | Name | Description |
---|---|---|
Function1<T, Future<R>> | resolveFunction | The resolve function. |
Action1<System.Exception> | rejectAction | The reject action. |
Returns
Type | Description |
---|---|
Future<R> |
Type Parameters
Name | Description |
---|---|
R |
Overrides
Wrap(Action0)
Creates a promise and resolves it after invoking a callback action, or rejects it if an exception is thrown.
Declaration
public static Future<object> Wrap(Action0 callbackAction)
Parameters
Type | Name | Description |
---|---|---|
Action0 | callbackAction | The callback action. |
Returns
Type | Description |
---|---|
Future<System.Object> |
Wrap<R>(Function0<R>)
Creates a promise and resolves it using the result from a callback function, or rejects it if an exception is thrown.
Declaration
public static Future<R> Wrap<R>(Function0<R> callbackFunction)
where R : class
Parameters
Type | Name | Description |
---|---|---|
Function0<R> | callbackFunction | The callback function. |
Returns
Type | Description |
---|---|
Future<R> |
Type Parameters
Name | Description |
---|---|
R |
WrapAsync(Action0)
Creates a promise and resolves it after invoking a callback action, or rejects it if an exception is thrown. The callback is always dispatched to the background.
Declaration
public static Future<object> WrapAsync(Action0 callbackAction)
Parameters
Type | Name | Description |
---|---|---|
Action0 | callbackAction | The callback action. |
Returns
Type | Description |
---|---|
Future<System.Object> |
WrapAsync<R>(Function0<R>)
Creates a promise and resolves it using the result from a callback function, or rejects it if an exception is thrown. The callback is always dispatched to the background.
Declaration
public static Future<R> WrapAsync<R>(Function0<R> callbackFunction)
where R : class
Parameters
Type | Name | Description |
---|---|---|
Function0<R> | callbackFunction | The callback function. |
Returns
Type | Description |
---|---|
Future<R> |
Type Parameters
Name | Description |
---|---|
R |