Interface IPromise<PromisedT>
Namespace: RSG
Syntax
public interface IPromise<PromisedT>
Type Parameters
| Name |
Description |
| PromisedT |
|
Properties
Id
Gets the id of the promise, useful for referencing the promise during runtime.
Declaration
Property Value
isCompleted
Declaration
bool isCompleted { get; }
Property Value
Methods
Catch(Action<Exception>)
Handle errors for the promise.
Declaration
IPromise Catch(Action<Exception> onRejected)
Parameters
Returns
Catch(Func<Exception, PromisedT>)
Handle errors for the promise.
Declaration
IPromise<PromisedT> Catch(Func<Exception, PromisedT> onRejected)
Parameters
Returns
ContinueWith(Func<IPromise>)
Add a callback that chains a non-value promise.
ContinueWith callbacks will always be called, even if any preceding promise is rejected, or encounters an error.
The state of the returning promise will be based on the new non-value promise, not the preceding (rejected or resolved) promise.
Declaration
IPromise ContinueWith(Func<IPromise> onResolved)
Parameters
Returns
ContinueWith<ConvertedT>(Func<IPromise<ConvertedT>>)
Add a callback that chains a value promise (optionally converting to a different value type).
ContinueWith callbacks will always be called, even if any preceding promise is rejected, or encounters an error.
The state of the returning promise will be based on the new value promise, not the preceding (rejected or resolved) promise.
Declaration
IPromise<ConvertedT> ContinueWith<ConvertedT>(Func<IPromise<ConvertedT>> onComplete)
Parameters
Returns
Type Parameters
| Name |
Description |
| ConvertedT |
|
Done()
Complete the promise. Adds a default error handler.
Declaration
Done(Action<PromisedT>)
Completes the promise.
onResolved is called on successful completion.
Adds a default error handler.
Declaration
void Done(Action<PromisedT> onResolved)
Parameters
| Type |
Name |
Description |
| Action<PromisedT> |
onResolved |
|
Done(Action<PromisedT>, Action<Exception>)
Completes the promise.
onResolved is called on successful completion.
onRejected is called on error.
Declaration
void Done(Action<PromisedT> onResolved, Action<Exception> onRejected)
Parameters
Finally(Action)
Add a finally callback.
Finally callbacks will always be called, even if any preceding promise is rejected, or encounters an error.
The returned promise will be resolved or rejected, as per the preceding promise.
Declaration
IPromise<PromisedT> Finally(Action onComplete)
Parameters
| Type |
Name |
Description |
| Action |
onComplete |
|
Returns
Progress(Action<Single>)
Add a progress callback.
Progress callbacks will be called whenever the promise owner reports progress towards the resolution
of the promise.
Declaration
IPromise<PromisedT> Progress(Action<float> onProgress)
Parameters
Returns
Then(Action<PromisedT>)
Declaration
IPromise Then(Action<PromisedT> onResolved)
Parameters
| Type |
Name |
Description |
| Action<PromisedT> |
onResolved |
|
Returns
Then(Action<PromisedT>, Action<Exception>)
Add a resolved callback and a rejected callback.
Declaration
IPromise Then(Action<PromisedT> onResolved, Action<Exception> onRejected)
Parameters
Returns
Then(Action<PromisedT>, Action<Exception>, Action<Single>)
Add a resolved callback, a rejected callback and a progress callback.
Declaration
IPromise Then(Action<PromisedT> onResolved, Action<Exception> onRejected, Action<float> onProgress)
Parameters
Returns
Then(Func<PromisedT, IPromise>)
Add a resolved callback that chains a non-value promise.
Declaration
IPromise Then(Func<PromisedT, IPromise> onResolved)
Parameters
Returns
Then(Func<PromisedT, IPromise>, Action<Exception>)
Add a resolved callback and a rejected callback.
The resolved callback chains a non-value promise.
Declaration
IPromise Then(Func<PromisedT, IPromise> onResolved, Action<Exception> onRejected)
Parameters
Returns
Then(Func<PromisedT, IPromise>, Action<Exception>, Action<Single>)
Add a resolved callback, a rejected callback and a progress callback.
The resolved callback chains a non-value promise.
Declaration
IPromise Then(Func<PromisedT, IPromise> onResolved, Action<Exception> onRejected, Action<float> onProgress)
Parameters
Returns
Then<ConvertedT>(Func<PromisedT, ConvertedT>)
Return a new promise with a different value.
May also change the type of the value.
Declaration
IPromise<ConvertedT> Then<ConvertedT>(Func<PromisedT, ConvertedT> transform)
Parameters
| Type |
Name |
Description |
| Func<PromisedT, ConvertedT> |
transform |
|
Returns
Type Parameters
| Name |
Description |
| ConvertedT |
|
Then<ConvertedT>(Func<PromisedT, IPromise<ConvertedT>>)
Add a resolved callback that chains a value promise (optionally converting to a different value type).
Declaration
IPromise<ConvertedT> Then<ConvertedT>(Func<PromisedT, IPromise<ConvertedT>> onResolved)
Parameters
| Type |
Name |
Description |
| Func<PromisedT, IPromise<ConvertedT>> |
onResolved |
|
Returns
Type Parameters
| Name |
Description |
| ConvertedT |
|
Then<ConvertedT>(Func<PromisedT, IPromise<ConvertedT>>, Func<Exception, IPromise<ConvertedT>>)
Add a resolved callback and a rejected callback.
The resolved callback chains a value promise (optionally converting to a different value type).
Declaration
IPromise<ConvertedT> Then<ConvertedT>(Func<PromisedT, IPromise<ConvertedT>> onResolved, Func<Exception, IPromise<ConvertedT>> onRejected)
Parameters
Returns
Type Parameters
| Name |
Description |
| ConvertedT |
|
Then<ConvertedT>(Func<PromisedT, IPromise<ConvertedT>>, Func<Exception, IPromise<ConvertedT>>, Action<Single>)
Add a resolved callback, a rejected callback and a progress callback.
The resolved callback chains a value promise (optionally converting to a different value type).
Declaration
IPromise<ConvertedT> Then<ConvertedT>(Func<PromisedT, IPromise<ConvertedT>> onResolved, Func<Exception, IPromise<ConvertedT>> onRejected, Action<float> onProgress)
Parameters
Returns
Type Parameters
| Name |
Description |
| ConvertedT |
|
ThenAll(Func<PromisedT, IEnumerable<IPromise>>)
Chain an enumerable of promises, all of which must resolve.
Converts to a non-value promise.
The resulting promise is resolved when all of the promises have resolved.
It is rejected as soon as any of the promises have been rejected.
Declaration
IPromise ThenAll(Func<PromisedT, IEnumerable<IPromise>> chain)
Parameters
Returns
ThenAll<ConvertedT>(Func<PromisedT, IEnumerable<IPromise<ConvertedT>>>)
Chain an enumerable of promises, all of which must resolve.
Returns a promise for a collection of the resolved results.
The resulting promise is resolved when all of the promises have resolved.
It is rejected as soon as any of the promises have been rejected.
Declaration
IPromise<IEnumerable<ConvertedT>> ThenAll<ConvertedT>(Func<PromisedT, IEnumerable<IPromise<ConvertedT>>> chain)
Parameters
Returns
Type Parameters
| Name |
Description |
| ConvertedT |
|
ThenRace(Func<PromisedT, IEnumerable<IPromise>>)
Takes a function that yields an enumerable of promises.
Converts to a non-value promise.
Returns a promise that resolves when the first of the promises has resolved.
Yields the value from the first promise that has resolved.
Declaration
IPromise ThenRace(Func<PromisedT, IEnumerable<IPromise>> chain)
Parameters
Returns
ThenRace<ConvertedT>(Func<PromisedT, IEnumerable<IPromise<ConvertedT>>>)
Takes a function that yields an enumerable of promises.
Returns a promise that resolves when the first of the promises has resolved.
Yields the value from the first promise that has resolved.
Declaration
IPromise<ConvertedT> ThenRace<ConvertedT>(Func<PromisedT, IEnumerable<IPromise<ConvertedT>>> chain)
Parameters
Returns
Type Parameters
| Name |
Description |
| ConvertedT |
|
WithName(String)
Set the name of the promise, useful for debugging.
Declaration
IPromise<PromisedT> WithName(string name)
Parameters
| Type |
Name |
Description |
| String |
name |
|
Returns