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 specifiedTKMPromise
instances complete successfully. In this case, the returnedTKMPromise
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 returnedTKMPromise
will resolve to theError
of the first failedTKMPromise
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 specifiedTKMPromise
instances complete successfully. In this case, the returnedTKMPromise
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 returnedTKMPromise
will resolve to theError
of the first failedTKMPromise
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 specifiedTKMPromise
instances complete successfully. In this case, the returnedTKMPromise
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 returnedTKMPromise
will resolve to theError
of the first failedTKMPromise
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. TheTKMAsyncResult
instances that the specifiedTKMPromise
instances resolve to will be returned in the result of the returnedTKMPromise
. -
Asynchronously waits for all specified promises to complete, regardless, whether they complete successfully or with an
Error
. The returned instance will always complete successfully. TheTKMAsyncResult
instances that the specifiedTKMPromise
instances resolve to will be returned in the result of the returnedTKMPromise
. -
Asynchronously waits for all specified promises to complete, regardless, whether they complete successfully or with an
Error
. The returned instance will always complete successfully. TheTKMAsyncResult
instances that the specifiedTKMPromise
instances resolve to will be returned in the result of the returnedTKMPromise
. -
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 raisedError
. -
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 returnedTKMPromise
will resolve to the correspondingError
. -
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:- all items have been iterated, processed successfully and resolved to
TKMLoopResult.continue
ornil
- the
TKMPromise
returned by the async function resolved toTKMLoopResult.break
. - the
TKMPromise
returned by the async function completed exceptionally.
In the last case the returned
TKMPromise
resolves to theError
returned by the async function. In all other cases the returnedTKMPromise
resolves to null. - all items have been iterated, processed successfully and resolved to
-
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:- all values have been iterated, processed successfully and resolved to
nil
orTKMLoopResult.continue
. - the
TKMPromise
returned by the async function resolved toTKMLoopResult.break
. - the
TKMPromise
returned by the async function completed exceptionally.
In the last case the returned
TKMPromise
resolves to theError
returned by the async function. In all other cases the returnedTKMPromise
resolves tonil
. - all values have been iterated, processed successfully and resolved to
-
Executes the given async function until one of the following happens:
- the
TKMPromise
returned by the async function resolved to something other thanTKMLoopResult.continue
ornil
(i.e.TKMLoopResult.continue
). - the
TKMPromise
returned by the async function completed exceptionally.
In the latter case the returned
TKMPromise
resolves to theError
returned by the async function. In the first case the returnedTKMPromise
resolves tonil
. - the
-
Returns a
TKMPromise<T>
that completes after either the given time span elapsed or the givenTKMCancellationToken
requested cancellation. In the first case, the returnedTKMPromise<T>
completes successfully while in the second case it completes exceptionally with anTKMRuntimeError.cancellationError
. -
Returns a completed
TKMPromise<T>
that resolves to null. -
Synchronously executes the given
TKMAction
and then returns a completedTKMPromise<T>
that resolves to null. If execution of the action fails, the returned promise completes exceptionally and resolves to the raisedError
. -
Executes the given
TKMFunc
and returns theTKMPromise<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.