Show / Hide Table of Contents

Class Promise

Promise-related helpers.

Inheritance
Object
Promise
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: UnityFx.Async.Promises
Assembly: UnityFx.Async-netstandard2.0.dll
Syntax
public static class Promise

Methods

| Improve this Doc View Source

All(IEnumerable<IAsyncOperation>)

Returns a promise that resolves when all of the promises in the enumerable argument have resolved.

Declaration
public static IAsyncOperation All(IEnumerable<IAsyncOperation> ops)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<IAsyncOperation> ops

Operations to wait for.

Returns
Type Description
IAsyncOperation

An operation that completes when all specified promises are resolved.

Exceptions
Type Condition
ArgumentNullException

Thrown if ops is null.

ArgumentException

Thrown if the ops collection contained a null operation.

See Also
All(IAsyncOperation[])
| Improve this Doc View Source

All(IAsyncOperation[])

Returns a promise that resolves when all of the promises in the enumerable argument have resolved.

Declaration
public static IAsyncOperation All(params IAsyncOperation[] ops)
Parameters
Type Name Description
IAsyncOperation[] ops

Operations to wait for.

Returns
Type Description
IAsyncOperation

An operation that completes when all specified promises are resolved.

Exceptions
Type Condition
ArgumentNullException

Thrown if ops is null.

ArgumentException

Thrown if the ops collection contained a null operation.

See Also
All(IEnumerable<IAsyncOperation>)
| Improve this Doc View Source

Race(IEnumerable<IAsyncOperation>)

Returns a promise that resolves when any of the promises in the enumerable argument have resolved.

Declaration
public static IAsyncOperation Race(IEnumerable<IAsyncOperation> ops)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<IAsyncOperation> ops

Operations to wait for.

Returns
Type Description
IAsyncOperation

An operation that completes when any of the specified promises is resolved.

Exceptions
Type Condition
ArgumentNullException

Thrown if ops is null.

ArgumentException

Thrown if the ops collection contained a null operation.

See Also
Race(IAsyncOperation[])
| Improve this Doc View Source

Race(IAsyncOperation[])

Returns a promise that resolves when any of the promises in the enumerable argument have resolved.

Declaration
public static IAsyncOperation Race(params IAsyncOperation[] ops)
Parameters
Type Name Description
IAsyncOperation[] ops

Operations to wait for.

Returns
Type Description
IAsyncOperation

An operation that completes when any of the specified promises is resolved.

Exceptions
Type Condition
ArgumentNullException

Thrown if ops is null.

ArgumentException

Thrown if the ops collection contained a null operation.

See Also
Race(IEnumerable<IAsyncOperation>)
| Improve this Doc View Source

Rejected()

Creates a promise that's already been rejected.

Declaration
public static IAsyncOperation Rejected()
Returns
Type Description
IAsyncOperation
See Also
Rejected(String)
Rejected(Exception)
Resolved()
| Improve this Doc View Source

Rejected(Exception)

Creates a promise that's already been rejected with the specified Exception.

Declaration
public static IAsyncOperation Rejected(Exception e)
Parameters
Type Name Description
Exception e
Returns
Type Description
IAsyncOperation
Exceptions
Type Condition
ArgumentNullException

Thrown if e is null.

See Also
Rejected(String)
Rejected()
Resolved()
| Improve this Doc View Source

Rejected(String)

Creates a promise that's already been rejected with the specified error message.

Declaration
public static IAsyncOperation Rejected(string message)
Parameters
Type Name Description
String message
Returns
Type Description
IAsyncOperation
See Also
Rejected(Exception)
Rejected()
Resolved()
| Improve this Doc View Source

Resolved()

Creates a promise that's already been resolved.

Declaration
public static IAsyncOperation Resolved()
Returns
Type Description
IAsyncOperation
See Also
Rejected(Exception)
Resolved<TResult>(TResult)
| Improve this Doc View Source

Resolved<TResult>(TResult)

Creates a promise that's already been resolved with the specified value.

Declaration
public static IAsyncOperation<TResult> Resolved<TResult>(TResult result)
Parameters
Type Name Description
TResult result
Returns
Type Description
IAsyncOperation<TResult>
Type Parameters
Name Description
TResult
See Also
Rejected(Exception)
Resolved()
| Improve this Doc View Source

Sequence(IEnumerable<Func<IAsyncOperation>>)

Chain a number of operations using promises.

Declaration
public static IAsyncOperation Sequence(IEnumerable<Func<IAsyncOperation>> ops)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.Func<IAsyncOperation>> ops

Functions each of which starts an async operation and yields a promise.

Returns
Type Description
IAsyncOperation

An operation that completes when all promises in the sequence are resolved.

Exceptions
Type Condition
ArgumentNullException

Thrown if ops is null.

ArgumentException

Thrown if the ops collection contained a null operation.

See Also
Sequence(Func<IAsyncOperation>[])
| Improve this Doc View Source

Sequence(Func<IAsyncOperation>[])

Chain a number of operations using promises.

Declaration
public static IAsyncOperation Sequence(params Func<IAsyncOperation>[] ops)
Parameters
Type Name Description
System.Func<IAsyncOperation>[] ops

Functions each of which starts an async operation and yields a promise.

Returns
Type Description
IAsyncOperation

An operation that completes when all promises in the sequence are resolved.

Exceptions
Type Condition
ArgumentNullException

Thrown if ops is null.

ArgumentException

Thrown if the ops collection contained a null operation.

See Also
Sequence(IEnumerable<Func<IAsyncOperation>>)

Events

| Improve this Doc View Source

UnhandledException

Event raised for unhandled exceptions. For this to work you have to complete your promises with a call to Done().

Declaration
public static event EventHandler<ExceptionEventArgs> UnhandledException
Event Type
Type Description
System.EventHandler<ExceptionEventArgs>

See Also

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
  • Improve this Doc
  • View Source
Back to top Copyright (c) 2017-2018 Alexander Bogarsukov