OmhTask
open class OmhTask<T>(task: suspend () -> T, coroutineContext: CoroutineContext = Dispatchers.IO + SupervisorJob(), customScope: CoroutineScope = CoroutineScope(context = coroutineContext)) : BaseOmhTask<T>
A wrapper class for the async library that's used in a specific OMH implementation. This creates a layer of abstraction between the developer and the library that doesn't force the preferred async library on them.
This will work akin to the Rx libraries which give you a disposable object to cancel any async functionalities that are in execution, thus giving you a bit of control over the async operations. It also allows you to add onSuccess and onFailure listeners in a modular way to react to the outcomes.
The execute function is important to obtain the OmhCancellable that allows you to cancel any currently running async operation. Because not all libraries have a way to cancel async operations, the OmhCancellable is returned as nullable.
Constructors
Link copied to clipboard
constructor(task: suspend () -> T, coroutineContext: CoroutineContext = Dispatchers.IO + SupervisorJob(), customScope: CoroutineScope = CoroutineScope(context = coroutineContext))