Interface IPromise | Package Manager UI website
docs.unity3d.com
    Show / Hide Table of Contents

    Interface IPromise

    Implements a non-generic C# promise, this is a promise that simply resolves without delivering a value. https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise

    Namespace: RSG
    Syntax
    public interface IPromise

    Properties

    Id

    ID of the promise, useful for debugging.

    Declaration
    int Id { get; }
    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
    Type Description
    IPromise

    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
    Type Description
    IPromise

    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 Description
    IPromise<ConvertedT>
    Type Parameters
    Name Description
    ConvertedT

    Done()

    Complete the promise. Adds a default error handler.

    Declaration
    void Done()

    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
    Type Description
    IPromise

    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
    Type Description
    IPromise

    Then(Action)

    Add a resolved callback.

    Declaration
    IPromise Then(Action onResolved)
    Parameters
    Type Name Description
    System.Action onResolved
    Returns
    Type Description
    IPromise

    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
    Type Description
    IPromise

    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
    Type Description
    IPromise

    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
    Type Description
    IPromise

    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
    Type Description
    IPromise

    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
    Type Description
    IPromise

    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 Description
    IPromise<ConvertedT>
    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 Description
    IPromise<ConvertedT>
    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 Description
    IPromise<ConvertedT>
    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
    Type Description
    IPromise

    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
    Type Description
    IPromise

    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 Description
    IPromise<ConvertedT>
    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
    Type Description
    IPromise

    WithName(String)

    Set the name of the promise, useful for debugging.

    Declaration
    IPromise WithName(string name)
    Parameters
    Type Name Description
    System.String name
    Returns
    Type Description
    IPromise
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023