Beamable SDK
Classes | Public Member Functions | Static Public Member Functions | Properties | List of all members
Beamable.Common.Promise< T > Class Template Reference

This type defines the Beamable Promise. More...

Inheritance diagram for Beamable.Common.Promise< T >:
Inheritance graph
[legend]
Collaboration diagram for Beamable.Common.Promise< T >:
Collaboration graph
[legend]

Public Member Functions

void CompleteSuccess (T val)
 Call to set the value and resolve the Promise More...
 
void CompleteError (Exception ex)
 Call to throw an exception and resolve the Promise More...
 
Promise< T > Then (Action< T > callback)
 Call to register a success completion handler callback for the Promise More...
 
Promise< T > Merge (Promise< T > other)
 Combine the outcome of this promise with the given promise. If this promise completes, the given promise will complete. If this promise fails, the given promise will fail. More...
 
Promise< T > Error (Action< Exception > errback)
 Call to register a failure completion handler callback for the Promise More...
 
Promise< TU > Map< TU > (Func< T, TU > callback)
 Takes a promise of type A, and returns a promise of type B with a conversion applied. More...
 
PromiseU FlatMap< PromiseU, U > (Func< T, PromiseU > callback, Func< PromiseU > factory)
 Takes a promise of type A, and returns a promise of type B with a conversion applied and the promise hierarchy is flattened. More...
 
Promise< TU > FlatMap< TU > (Func< T, Promise< TU > > callback)
 Takes a promise of type A, and returns a promise of type B with a conversion applied and the promise hierarchy is flattened. More...
 
GetResult ()
 Get the result of the Promise. More...
 
Promise< T > GetAwaiter ()
 Get the awaiter of the Promise. Once an awaiter is established, this promise will never raise an uncaught exception. More...
 
void CompleteSuccess ()
 

Static Public Member Functions

static Promise< T > Successful (T value)
 Call to set the value and resolve the Promise More...
 
static Promise< T > Failed (Exception err)
 Call to throw an exception and resolve the Promise More...
 
static SequencePromise< T > ObservableSequence< T > (IList< Promise< T > > promises)
 Create a SequencePromise<T> from List of Promise<T> More...
 
static Promise< List< T > > Sequence< T > (IList< Promise< T > > promises)
 Create a Promise of List from a List of Promises. More...
 
static Promise< List< T > > Sequence< T > (params Promise< T >[] promises)
 Create Sequence Promise from an array of Promises. More...
 
static Promise< UnitExecuteSerially< T > (List< Func< Promise< T > > > generators, Func< bool > stopWhen=null)
 Given a list of promise generator functions, process the whole list, but serially. Only one promise will be active at any given moment. More...
 
static SequencePromise< T > ExecuteRolling< T > (int maxProcessSize, List< Func< Promise< T > > > generators, Func< bool > stopWhen=null)
 Given a list of promise generator functions, process the list, but in a rolling fashion. More...
 
static Promise< UnitExecuteInBatch< T > (int maxBatchSize, List< Func< Promise< T > > > generators)
 Given a list of promise generator functions, process the list, but in batches of some size. The batches themselves will run one at a time. Every promise in the current batch must finish before the next batch can start. More...
 
static SequencePromise< T > ExecuteInBatchSequence< T > (int maxBatchSize, List< Func< Promise< T > > > generators, Func< bool > stopWhen=null)
 
- Static Public Member Functions inherited from Beamable.Common.PromiseBase
static void SetPotentialUncaughtErrorHandler (PromiseEvent handler, bool replaceExistingHandlers=true)
 Set error handlers for uncaught promise errors. Beamable has a default handler set in its API initialization. More...
 

Properties

static Promise Success = new Promise { done = true } [get]
 
- Properties inherited from Beamable.Common.PromiseBase
bool HadAnyErrbacks [getprotected set]
 True if there are any registered error handlers.
 
bool done [getset]
 
static Promise< UnitSuccessfulUnit [get]
 
bool IsCompleted [get]
 True when the promise has completed; false otherwise.
 
static bool HasUncaughtErrorHandler [get]
 

Additional Inherited Members

- Static Public Attributes inherited from Beamable.Common.PromiseBase
static readonly Unit Unit = new Unit()
 
- Protected Member Functions inherited from Beamable.Common.PromiseBase
void InvokeUncaughtPromise ()
 
- Protected Attributes inherited from Beamable.Common.PromiseBase
Action< Exception > errbacks
 
Exception err
 
ExceptionDispatchInfo errInfo
 
StackTrace _errStackTrace
 
object _lock = new object()
 

Detailed Description

This type defines the Beamable Promise.

A promise is an object that may produce a single value some time in the future: either a resolved value, or a reason that it’s not resolved (e.g., a network error occurred).

Related Links

img beamable-logo

Member Function Documentation

◆ CompleteError()

void Beamable.Common.Promise< T >.CompleteError ( Exception  ex)
inline

Call to throw an exception and resolve the Promise

Parameters
val

◆ CompleteSuccess()

void Beamable.Common.Promise< T >.CompleteSuccess ( val)
inline

Call to set the value and resolve the Promise

Parameters
val

◆ Error()

Promise< T > Beamable.Common.Promise< T >.Error ( Action< Exception >  errback)
inline

Call to register a failure completion handler callback for the Promise

Parameters
val

◆ ExecuteInBatch< T >()

static Promise< Unit > Beamable.Common.Promise< T >.ExecuteInBatch< T > ( int  maxBatchSize,
List< Func< Promise< T > > >  generators 
)
inlinestatic

Given a list of promise generator functions, process the list, but in batches of some size. The batches themselves will run one at a time. Every promise in the current batch must finish before the next batch can start.

Parameters
maxBatchSize
generators
Template Parameters
T
Returns
A single promise of Unit to represent the completion of the processing. Any other side effects need to be handled separately

◆ ExecuteRolling< T >()

static SequencePromise< T > Beamable.Common.Promise< T >.ExecuteRolling< T > ( int  maxProcessSize,
List< Func< Promise< T > > >  generators,
Func< bool >  stopWhen = null 
)
inlinestatic

Given a list of promise generator functions, process the list, but in a rolling fashion.

Parameters
maxProcessSize
generators
stopWhen
Template Parameters
T
Returns

◆ ExecuteSerially< T >()

static Promise< Unit > Beamable.Common.Promise< T >.ExecuteSerially< T > ( List< Func< Promise< T > > >  generators,
Func< bool >  stopWhen = null 
)
inlinestatic

Given a list of promise generator functions, process the whole list, but serially. Only one promise will be active at any given moment.

Parameters
generators
Template Parameters
T
Returns
A single promise of Unit to represent the completion of the processing. Any other side effects need to be handled separately

◆ Failed()

static Promise< T > Beamable.Common.Promise< T >.Failed ( Exception  err)
inlinestatic

Call to throw an exception and resolve the Promise

Parameters
err
Returns

◆ FlatMap< PromiseU, U >()

PromiseU Beamable.Common.Promise< T >.FlatMap< PromiseU, U > ( Func< T, PromiseU >  callback,
Func< PromiseU >  factory 
)
inline

Takes a promise of type A, and returns a promise of type B with a conversion applied and the promise hierarchy is flattened.

Parameters
callback
factory
Template Parameters
PromiseU
U
Returns
Type Constraints
PromiseU :Promise<U> 

◆ FlatMap< TU >()

Promise< TU > Beamable.Common.Promise< T >.FlatMap< TU > ( Func< T, Promise< TU > >  callback)
inline

Takes a promise of type A, and returns a promise of type B with a conversion applied and the promise hierarchy is flattened.

Parameters
callback
Template Parameters
TU
Returns

◆ GetAwaiter()

Promise< T > Beamable.Common.Promise< T >.GetAwaiter ( )
inline

Get the awaiter of the Promise. Once an awaiter is established, this promise will never raise an uncaught exception.

Returns
Exceptions
Exception

◆ GetResult()

T Beamable.Common.Promise< T >.GetResult ( )
inline

Get the result of the Promise.

Returns
Exceptions
Exception

◆ Map< TU >()

Promise< TU > Beamable.Common.Promise< T >.Map< TU > ( Func< T, TU >  callback)
inline

Takes a promise of type A, and returns a promise of type B with a conversion applied.

Parameters
callback
Template Parameters
TU
Returns

◆ Merge()

Promise< T > Beamable.Common.Promise< T >.Merge ( Promise< T >  other)
inline

Combine the outcome of this promise with the given promise. If this promise completes, the given promise will complete. If this promise fails, the given promise will fail.

Parameters
otherSome promise other than this promise.
Returns
The current promise instance

◆ ObservableSequence< T >()

static SequencePromise< T > Beamable.Common.Promise< T >.ObservableSequence< T > ( IList< Promise< T > >  promises)
inlinestatic

Create a SequencePromise<T> from List of Promise<T>

Parameters
promises
Template Parameters
T
Returns

◆ Sequence< T >() [1/2]

static Promise< List< T > > Beamable.Common.Promise< T >.Sequence< T > ( IList< Promise< T > >  promises)
inlinestatic

Create a Promise of List from a List of Promises.

Parameters
promises
Template Parameters
T
Returns

◆ Sequence< T >() [2/2]

static Promise< List< T > > Beamable.Common.Promise< T >.Sequence< T > ( params Promise< T >[]  promises)
inlinestatic

Create Sequence Promise from an array of Promises.

Parameters
promises
Template Parameters
T
Returns

◆ Successful()

static Promise< T > Beamable.Common.Promise< T >.Successful ( value)
inlinestatic

Call to set the value and resolve the Promise

Parameters
value
Returns

◆ Then()

Promise< T > Beamable.Common.Promise< T >.Then ( Action< T >  callback)
inline

Call to register a success completion handler callback for the Promise

Parameters
val

The documentation for this class was generated from the following file: