![]() |
CotC C# SDK for Unity
v1.4.0.1
Making social games is easy !
|
Promise of future result, which may fail or succeed. Returned as a result of any asnychronous operation.
Complies to the standard Promise specification: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise
Used throughout most API calls to ease the manipulation of asynchronous methods. See this chapter for a tutorial on how to use promises with the SDK.
PromisedT | Expected result type (in case of success, else an exception is returned). |
Properties | |
static EventHandler< ExceptionEventArgs > | UnhandledException |
Event raised for unhandled errors. For this to work you have to complete your promises with a call to Done(). More... | |
Public Member Functions | |
Promise< PromisedT > | Catch (Action< Exception > onRejected) |
Catches a failure at that point in the chain. More... | |
void | Done (Action< PromisedT > onResolved, Action< Exception > onRejected) |
Put this at the end of a promise chain. It ensures that unhandled exceptions can be delivered properly. More... | |
void | Done (Action< PromisedT > onResolved) |
Put this at the end of a promise chain. More... | |
void | Done () |
Put this at the end of a promise chain. It ensures that unhandled exceptions can be delivered properly. More... | |
void | Reject (Exception ex) |
Reject this promise (indicate that the process failed for some reason). More... | |
void | Resolve (PromisedT value) |
Resolves the promise, i.e. notifies a successful result of the async operation. More... | |
Promise< ConvertedT > | Then< ConvertedT > (Func< PromisedT, Promise< ConvertedT >> onResolved) |
Add a resolved callback and a rejected callback. The resolved callback chains a value promise (optionally converting to a different value type). More... | |
Promise< PromisedT > | Then (Action< PromisedT > onResolved) |
Registers a block of code to be executed when the promise returns a successful result. More... | |
Promise< PromisedT > | Then (Action< PromisedT > onResolved, Action< Exception > onRejected) |
Add a resolved callback and a rejected callback. The resolved callback chains a non-value promise. More... | |
Promise< ConvertedT > | Then< ConvertedT > (Func< PromisedT, Promise< ConvertedT >> onResolved, Action< Exception > onRejected) |
Adds a resolved and rejected callback. Allows for chaining (i.e. return another promise, potentially of another type, indicating an operation to be waited for). Example: More... | |
override string | ToString () |
Gets some Promise's stats as a human readable string, like its state and its resolved/rejected callbacks counts. More... | |
Promise | Catch (Action< Exception > onRejected) |
Catches a failure at that point in the chain. More... | |
void | Done (Action onResolved, Action< Exception > onRejected) |
Put this at the end of a promise chain. It ensures that unhandled exceptions can be delivered properly. More... | |
void | Done (Action onResolved) |
Put this at the end of a promise chain. More... | |
void | Done () |
Put this at the end of a promise chain. It ensures that unhandled exceptions can be delivered properly. More... | |
void | Reject (Exception ex) |
Reject this promise (indicate that the process failed for some reason). More... | |
void | Resolve () |
Resolves the promise, i.e. notifies a successful result of the async operation. More... | |
Promise< ConvertedT > | Then< ConvertedT > (Func< Promise< ConvertedT >> onResolved) |
Add a resolved callback and a rejected callback. The resolved callback chains a value promise (optionally converting to a different value type). More... | |
Promise | Then (Action onResolved) |
Registers a block of code to be executed when the promise returns a successful result. More... | |
Promise | Then (Action onResolved, Action< Exception > onRejected) |
Add a resolved callback and a rejected callback. The resolved callback chains a non-value promise. More... | |
Promise | Then (Func< Promise > onResolved) |
Registers a block of code to be executed when the promise returns a successful result. More... | |
Promise | Then (Func< Promise > onResolved, Action< Exception > onRejected) |
Add a resolved callback and a rejected callback. The resolved callback chains a non-value promise. More... | |
Promise< ConvertedT > | Then< ConvertedT > (Func< Promise< ConvertedT >> onResolved, Action< Exception > onRejected) |
Adds a resolved and rejected callback. Allows for chaining (i.e. return another promise, potentially of another type, indicating an operation to be waited for). Example: More... | |
override string | ToString () |
Gets some Promise's stats as a human readable string, like its state and its resolved/rejected callbacks counts. More... | |
Static Public Member Functions | |
static Promise< PromisedT > | Rejected (Exception ex) |
Shorthand to create a promise that is already rejected. More... | |
static Promise | Rejected (Exception ex) |
Shorthand to create a promise that is already rejected. More... | |
Static Public Attributes | |
static bool | Debug_OutputAllExceptions = true |
Set this to true in order to output any exception to the console, even if it is caught by a .Catch block. Just a helper, never keep it true in production. More... | |
|
staticaddremove |
Event raised for unhandled errors. For this to work you have to complete your promises with a call to Done().
Promise<PromisedT> CotcSdk.Promise< PromisedT >.Catch | ( | Action< Exception > | onRejected | ) |
Catches a failure at that point in the chain.
onRejected | Block handling the exception. |
Promise CotcSdk.Promise< PromisedT >.Catch | ( | Action< Exception > | onRejected | ) |
Catches a failure at that point in the chain.
onRejected | Block handling the exception. |
void CotcSdk.Promise< PromisedT >.Done | ( | Action< PromisedT > | onResolved, |
Action< Exception > | onRejected | ||
) |
Put this at the end of a promise chain. It ensures that unhandled exceptions can be delivered properly.
onResolved | Execute upon success of all the chain steps. |
onRejected | Execute upon rejection of the promise chain (any failure within the chain). |
void CotcSdk.Promise< PromisedT >.Done | ( | Action | onResolved, |
Action< Exception > | onRejected | ||
) |
Put this at the end of a promise chain. It ensures that unhandled exceptions can be delivered properly.
onResolved | Execute upon success of all the chain steps. |
onRejected | Execute upon rejection of the promise chain (any failure within the chain). |
void CotcSdk.Promise< PromisedT >.Done | ( | Action< PromisedT > | onResolved | ) |
Put this at the end of a promise chain.
onResolved | Execute upon success (as is, this is nearly equivalent to providing a simple Then block, except that you can not do further chain the promise. Therefore, it ensures that an exception not handled at that point will never be and allows unhandled exceptions to be delivered properly. |
void CotcSdk.Promise< PromisedT >.Done | ( | ) |
Put this at the end of a promise chain. It ensures that unhandled exceptions can be delivered properly.
void CotcSdk.Promise< PromisedT >.Done | ( | Action | onResolved | ) |
Put this at the end of a promise chain.
onResolved | Execute upon success (as is, this is nearly equivalent to providing a simple Then block, except that you can not do further chain the promise. Therefore, it ensures that an exception not handled at that point will never be and allows unhandled exceptions to be delivered properly. |
void CotcSdk.Promise< PromisedT >.Done | ( | ) |
Put this at the end of a promise chain. It ensures that unhandled exceptions can be delivered properly.
void CotcSdk.Promise< PromisedT >.Reject | ( | Exception | ex | ) |
Reject this promise (indicate that the process failed for some reason).
ex | Exception to return as the failure result. |
void CotcSdk.Promise< PromisedT >.Reject | ( | Exception | ex | ) |
Reject this promise (indicate that the process failed for some reason).
ex | Exception to return as the failure result. |
|
static |
Shorthand to create a promise that is already rejected.
ex | Exception to reject the promise with. |
|
static |
Shorthand to create a promise that is already rejected.
ex | Exception to reject the promise with. |
void CotcSdk.Promise< PromisedT >.Resolve | ( | PromisedT | value | ) |
Resolves the promise, i.e. notifies a successful result of the async operation.
value | Result of the async operation. Caught by subscribers to this promise via a Then block. |
void CotcSdk.Promise< PromisedT >.Resolve | ( | ) |
Resolves the promise, i.e. notifies a successful result of the async operation.
Promise<PromisedT> CotcSdk.Promise< PromisedT >.Then | ( | Action< PromisedT > | onResolved | ) |
Registers a block of code to be executed when the promise returns a successful result.
onResolved | Executed upon successful result. |
Promise CotcSdk.Promise< PromisedT >.Then | ( | Action | onResolved | ) |
Registers a block of code to be executed when the promise returns a successful result.
onResolved | Executed upon successful result. |
Promise<PromisedT> CotcSdk.Promise< PromisedT >.Then | ( | Action< PromisedT > | onResolved, |
Action< Exception > | onRejected | ||
) |
Add a resolved callback and a rejected callback. The resolved callback chains a non-value promise.
onResolved | Executed upon successful result. |
onRejected | Executed upon failure (promise rejected). |
Promise CotcSdk.Promise< PromisedT >.Then | ( | Action | onResolved, |
Action< Exception > | onRejected | ||
) |
Add a resolved callback and a rejected callback. The resolved callback chains a non-value promise.
onResolved | Executed upon successful result. |
onRejected | Executed upon failure (promise rejected). |
Promise CotcSdk.Promise< PromisedT >.Then | ( | Func< Promise< PromisedT > > | onResolved | ) |
Registers a block of code to be executed when the promise returns a successful result.
onResolved | Executed upon successful result. |
Promise CotcSdk.Promise< PromisedT >.Then | ( | Func< Promise< PromisedT > > | onResolved, |
Action< Exception > | onRejected | ||
) |
Add a resolved callback and a rejected callback. The resolved callback chains a non-value promise.
onResolved | Executed upon successful result. |
onRejected | Executed upon failure (promise rejected). |
Promise<ConvertedT> CotcSdk.Promise< PromisedT >.Then< ConvertedT > | ( | Func< PromisedT, Promise< ConvertedT >> | onResolved | ) |
Add a resolved callback and a rejected callback. The resolved callback chains a value promise (optionally converting to a different value type).
ConvertedT | Type of the expected result (it should be guessed automatically). |
onResolved | Executed upon successful result. |
Promise<ConvertedT> CotcSdk.Promise< PromisedT >.Then< ConvertedT > | ( | Func< Promise< ConvertedT >> | onResolved | ) |
Add a resolved callback and a rejected callback. The resolved callback chains a value promise (optionally converting to a different value type).
ConvertedT | Type of the expected result (it should be guessed automatically). |
onResolved | Executed upon successful result. |
Promise<ConvertedT> CotcSdk.Promise< PromisedT >.Then< ConvertedT > | ( | Func< PromisedT, Promise< ConvertedT >> | onResolved, |
Action< Exception > | onRejected | ||
) |
Adds a resolved and rejected callback. Allows for chaining (i.e. return another promise, potentially of another type, indicating an operation to be waited for). Example:
ConvertedT | Type of the returned promise (should be guessed automatically). |
onResolved | Executed upon successful result. |
onRejected | Executed upon failure (promise rejected). |
Promise<ConvertedT> CotcSdk.Promise< PromisedT >.Then< ConvertedT > | ( | Func< Promise< ConvertedT >> | onResolved, |
Action< Exception > | onRejected | ||
) |
Adds a resolved and rejected callback. Allows for chaining (i.e. return another promise, potentially of another type, indicating an operation to be waited for). Example:
ConvertedT | Type of the returned promise (should be guessed automatically). |
onResolved | Executed upon successful result. |
onRejected | Executed upon failure (promise rejected). |
override string CotcSdk.Promise< PromisedT >.ToString | ( | ) |
override string CotcSdk.Promise< PromisedT >.ToString | ( | ) |
|
static |
Set this to true in order to output any exception to the console, even if it is caught by a .Catch block. Just a helper, never keep it true in production.