Interface IPromise
Namespace: RSG
Syntax
public interface IPromise
Properties
Id
ID of the promise, useful for debugging.
Declaration
Property Value
Type |
Description |
System.Int32 |
|
Methods
Catch(Action<Exception>)
Handle errors for the promise.
Declaration
IPromise Catch(Action<Exception> onRejected)
Parameters
Type |
Name |
Description |
System.Action<System.Exception> |
onRejected |
|
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
Type |
Name |
Description |
System.Func<IPromise> |
onResolved |
|
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
Type |
Name |
Description |
System.Func<IPromise<ConvertedT>> |
onComplete |
|
Returns
Type Parameters
Name |
Description |
ConvertedT |
|
Done()
Complete the promise. Adds a default error handler.
Declaration
Done(Action)
Completes the promise.
onResolved is called on successful completion.
Adds a default error handler.
Declaration
void Done(Action onResolved)
Parameters
Type |
Name |
Description |
System.Action |
onResolved |
|
Done(Action, Action<Exception>)
Completes the promise.
onResolved is called on successful completion.
onRejected is called on error.
Declaration
void Done(Action onResolved, Action<Exception> onRejected)
Parameters
Type |
Name |
Description |
System.Action |
onResolved |
|
System.Action<System.Exception> |
onRejected |
|
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 Finally(Action onComplete)
Parameters
Type |
Name |
Description |
System.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 Progress(Action<float> onProgress)
Parameters
Type |
Name |
Description |
System.Action<System.Single> |
onProgress |
|
Returns
Then(Action)
Declaration
IPromise Then(Action onResolved)
Parameters
Type |
Name |
Description |
System.Action |
onResolved |
|
Returns
Then(Action, Action<Exception>)
Add a resolved callback and a rejected callback.
Declaration
IPromise Then(Action onResolved, Action<Exception> onRejected)
Parameters
Type |
Name |
Description |
System.Action |
onResolved |
|
System.Action<System.Exception> |
onRejected |
|
Returns
Then(Action, Action<Exception>, Action<Single>)
Add a resolved callback, a rejected callback and a progress callback.
Declaration
IPromise Then(Action onResolved, Action<Exception> onRejected, Action<float> onProgress)
Parameters
Type |
Name |
Description |
System.Action |
onResolved |
|
System.Action<System.Exception> |
onRejected |
|
System.Action<System.Single> |
onProgress |
|
Returns
Then(Func<IPromise>)
Add a resolved callback that chains a non-value promise.
Declaration
IPromise Then(Func<IPromise> onResolved)
Parameters
Type |
Name |
Description |
System.Func<IPromise> |
onResolved |
|
Returns
Then(Func<IPromise>, Action<Exception>)
Add a resolved callback and a rejected callback.
The resolved callback chains a non-value promise.
Declaration
IPromise Then(Func<IPromise> onResolved, Action<Exception> onRejected)
Parameters
Type |
Name |
Description |
System.Func<IPromise> |
onResolved |
|
System.Action<System.Exception> |
onRejected |
|
Returns
Then(Func<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<IPromise> onResolved, Action<Exception> onRejected, Action<float> onProgress)
Parameters
Type |
Name |
Description |
System.Func<IPromise> |
onResolved |
|
System.Action<System.Exception> |
onRejected |
|
System.Action<System.Single> |
onProgress |
|
Returns
Then<ConvertedT>(Func<IPromise<ConvertedT>>)
Add a resolved callback that chains a value promise (optionally converting to a different value type).
Declaration
IPromise<ConvertedT> Then<ConvertedT>(Func<IPromise<ConvertedT>> onResolved)
Parameters
Type |
Name |
Description |
System.Func<IPromise<ConvertedT>> |
onResolved |
|
Returns
Type Parameters
Name |
Description |
ConvertedT |
|
Then<ConvertedT>(Func<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<IPromise<ConvertedT>> onResolved, Func<Exception, IPromise<ConvertedT>> onRejected)
Parameters
Type |
Name |
Description |
System.Func<IPromise<ConvertedT>> |
onResolved |
|
System.Func<System.Exception, IPromise<ConvertedT>> |
onRejected |
|
Returns
Type Parameters
Name |
Description |
ConvertedT |
|
Then<ConvertedT>(Func<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<IPromise<ConvertedT>> onResolved, Func<Exception, IPromise<ConvertedT>> onRejected, Action<float> onProgress)
Parameters
Type |
Name |
Description |
System.Func<IPromise<ConvertedT>> |
onResolved |
|
System.Func<System.Exception, IPromise<ConvertedT>> |
onRejected |
|
System.Action<System.Single> |
onProgress |
|
Returns
Type Parameters
Name |
Description |
ConvertedT |
|
ThenAll(Func<IEnumerable<IPromise>>)
Chain an enumerable of promises, all of which must resolve.
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<IEnumerable<IPromise>> chain)
Parameters
Type |
Name |
Description |
System.Func<System.Collections.Generic.IEnumerable<IPromise>> |
chain |
|
Returns
ThenAll<ConvertedT>(Func<IEnumerable<IPromise<ConvertedT>>>)
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<IEnumerable<ConvertedT>> ThenAll<ConvertedT>(Func<IEnumerable<IPromise<ConvertedT>>> chain)
Parameters
Type |
Name |
Description |
System.Func<System.Collections.Generic.IEnumerable<IPromise<ConvertedT>>> |
chain |
|
Returns
Type |
Description |
IPromise<System.Collections.Generic.IEnumerable<ConvertedT>> |
|
Type Parameters
Name |
Description |
ConvertedT |
|
ThenRace(Func<IEnumerable<IPromise>>)
Takes a function that yields an enumerable of promises.
Returns a promise that resolves when the first of the promises has resolved.
Declaration
IPromise ThenRace(Func<IEnumerable<IPromise>> chain)
Parameters
Type |
Name |
Description |
System.Func<System.Collections.Generic.IEnumerable<IPromise>> |
chain |
|
Returns
ThenRace<ConvertedT>(Func<IEnumerable<IPromise<ConvertedT>>>)
Takes a function that yields an enumerable of promises.
Converts to a value promise.
Returns a promise that resolves when the first of the promises has resolved.
Declaration
IPromise<ConvertedT> ThenRace<ConvertedT>(Func<IEnumerable<IPromise<ConvertedT>>> chain)
Parameters
Type |
Name |
Description |
System.Func<System.Collections.Generic.IEnumerable<IPromise<ConvertedT>>> |
chain |
|
Returns
Type Parameters
Name |
Description |
ConvertedT |
|
ThenSequence(Func<IEnumerable<Func<IPromise>>>)
Chain a sequence of operations using promises.
Reutrn a collection of functions each of which starts an async operation and yields a promise.
Each function will be called and each promise resolved in turn.
The resulting promise is resolved after each promise is resolved in sequence.
Declaration
IPromise ThenSequence(Func<IEnumerable<Func<IPromise>>> chain)
Parameters
Type |
Name |
Description |
System.Func<System.Collections.Generic.IEnumerable<System.Func<IPromise>>> |
chain |
|
Returns
WithName(String)
Set the name of the promise, useful for debugging.
Declaration
IPromise WithName(string name)
Parameters
Type |
Name |
Description |
System.String |
name |
|
Returns