TKMCancellationToken
public protocol TKMCancellationToken
Objects that allow cancelling long running operations. They are most often used to control async
program flows in conjunction with TKMPromise<T>
. Cancellation tokens can be produced using
See also
TKMCancellationTokenSource
See also
TKMPromise<T>
-
Returns whether cancellation has been requested.
Declaration
Swift
func isCancellationRequested() -> Bool
Return Value
true, if cancellation has already been requested, false if not.
-
When invoked, this method will cause this cancellation token to throw in the event of a cancellation request.
Declaration
Swift
func throwIfCancellationRequested() throws
-
Registers a function that is invoked when cancellation is requested. The callback is invoked on the current AsyncScheduler. If a listener is added while already in a cancelled state, this listener is called immediately and synchronously.
Declaration
Swift
func register(observer: @escaping () -> Void) -> TKMCancellationTokenRegistration
Parameters
observer
the action to invoke when cancellation is requested.
Return Value
an Observable that is invoked if cancellation is requested or immediately if already cancelled.
-
Registers a function that is invoked when cancellation is requested. If a listener is added while already in a cancelled state, this listener is called immediately and synchronously.
Declaration
Swift
func register(observer: @escaping () -> Void, useScheduler: Bool) -> TKMCancellationTokenRegistration
Parameters
observer
the action to invoke when cancellation is requested.
useScheduler
if set to true, the current AsyncScheduler is captured and used for invoking the callback.
Return Value
an Observable that is invoked if cancellation is requested or immediately if already cancelled.