TKMAsync

  • Creates a completed promise that resolves to the given value.

  • Creates a failed promise, that resolves to the given error.

  • Creates a completed promise that resolves to the given TKMAsyncResult.

  • Asynchronously waits for all specified promises to complete, regardless, whether they complete successfully or with an Error. The returned instance will complete successfully if all specified TKMPromise instances complete successfully. In this case, the returned TKMPromise resolves to a array of values corresponding to the values the specified promises resolved to. The order of the returned values corresponds to the order of the specified promises. If at least one of the specified promises fails, the returned TKMPromise will resolve to the Error of the first failed TKMPromise according to the order they have been specified.

  • Asynchronously waits for all specified promises to complete, regardless, whether they complete successfully or with an Error. The returned instance will complete successfully if all specified TKMPromise instances complete successfully. In this case, the returned TKMPromise resolves to a list of values corresponding to the values the specified promises resolved to. The order of the returned values corresponds to the order of the specified promises. If at least one of the specified promises fails, the returned TKMPromise will resolve to the Error of the first failed TKMPromise according to the order they have been specified.

  • Asynchronously waits for all specified promises to complete, regardless, whether they complete successfully or with an Error. The returned instance will complete successfully if all specified TKMPromise instances complete successfully. In this case, the returned TKMPromise resolves to a list of values corresponding to the values the specified promises resolved to. The order of the returned values corresponds to the order of the specified promises. If at least one of the specified promises fails, the returned TKMPromise will resolve to the Error of the first failed TKMPromise according to the order they have been specified.

  • Asynchronously waits for all specified promises to complete, regardless, whether they complete successfully or with an Error. The returned instance will always complete successfully. The TKMAsyncResult instances that the specifiedTKMPromise instances resolve to will be returned in the result of the returned TKMPromise.

  • Asynchronously waits for all specified promises to complete, regardless, whether they complete successfully or with an Error. The returned instance will always complete successfully. The TKMAsyncResult instances that the specifiedTKMPromise instances resolve to will be returned in the result of the returned TKMPromise.

  • Asynchronously waits for all specified promises to complete, regardless, whether they complete successfully or with an Error. The returned instance will always complete successfully. The TKMAsyncResult instances that the specifiedTKMPromise instances resolve to will be returned in the result of the returned TKMPromise.

  • Runs the specified operation on a multi-threaded worker-thread-backed scheduler. If the specified operation completes successfully, the returned TKMPromise<T> resolves to the returned value. Otherwise it will resolve to the raised Error.

  • Executes the specified function on the specified scheduler and returns a promise which will deliver the result on the caller’s current TKMAsyncScheduler.

  • Returns a TKMPromise<T> that completes after the given time span.

  • Iterates the given items and sequentially executes the given async functions for each item. The returned TKMPromise completes after asynchronous processing of all items has completed successfully. In this case the returnedTKMPromise resolves to a array containing the values the promises returned by the specified function resolved to. If execution of the specified function fails, iteration will stop and the returned TKMPromise will resolve to the corresponding Error.

  • Iterates the given items and sequentially executes the given async functions for each item. Execution stops, iteration ends and the returned TKMPromise completes if one of the following happens:

    In the last case the returned TKMPromise resolves to the Error returned by the async function. In all other cases the returned TKMPromise resolves to null.

  • Counts from 0 to n (excluding) and sequentially executes the given async functions for each value. Execution stops, iteration ends and the returned TKMPromise completes if one of the following happens:

    In the last case the returned TKMPromise resolves to the Error returned by the async function. In all other cases the returned TKMPromiseresolves to nil.

  • Executes the given async function until one of the following happens:

    In the latter case the returned TKMPromise resolves to the Error returned by the async function. In the first case the returnedTKMPromise resolves to nil.

  • Returns a TKMPromise<T> that completes after either the given time span elapsed or the given TKMCancellationToken requested cancellation. In the first case, the returned TKMPromise<T> completes successfully while in the second case it completes exceptionally with an TKMRuntimeError.cancellationError.

  • Returns a completed TKMPromise<T> that resolves to null.

  • Synchronously executes the given TKMAction and then returns a completed TKMPromise<T> that resolves to null. If execution of the action fails, the returned promise completes exceptionally and resolves to the raised Error.

  • Executes the given TKMFunc and returns the TKMPromise<T> returned by the function. The purpose of this function is to use it for structuring async code. It doesn’t provide any actual functionality.

    Instead of writing code like in this example

         firstAsyncOperation().continueAsyncOnUi { result ->
                 return secondAsyncOperation()
         }.continueAsyncOnUi { result ->
                 return thirdAsyncOperation()
         }.conclude()
    

    we could also write in a more readable way

         TKMAsync.firstAsync { () ->
                 return firstAsyncOperation()
         }.continueAsyncOnUi { result ->
                 return secondAsyncOperation()
         }.continueAsyncOnUi { result ->
                 return thirdAsyncOperation()
         }.conclude()
    
  • Starts an async function on the specified scheduler and continues the returned promise on the caller’s current scheduler.

  • Starts an async function on the specified scheduler and continues the returned promise on the other specified scheduler.