JobDispatcher

Dispatches a given job on a particular thread.

Examples

val future = JobDispatcher.dispatchOnMainThread("Hello") {it: String ->
assertEquals("Hello", it) // runs on main thread
}
future.await()

val future = JobDispatcher.dispatchOnBackgroundThread("Hello") {it: String ->
assertEquals("Hello", it) // runs on background thread
}
future.await()

object JobDispatcher

Functions

dispatchOnCurrentThread
Link copied to clipboard
common

Dispatches a non-capturing lambda job with jobInput as its input on the current thread. The jobInput is converted to an immutable object and then passed to the job as argument.

fun <T, V> dispatchOnCurrentThread(jobInput: T, job: (T) -> V): Future<V>
dispatchOnMainThread
Link copied to clipboard
common

Dispatches a non-capturing lambda job with jobInput as its input on the main thread. The jobInput is converted to an immutable object and then passed to the job as argument.

fun <T, V> dispatchOnMainThread(jobInput: T, job: (T) -> V): Future<V>
dispatchOnNewBackgroundThread
Link copied to clipboard
common

Dispatches a non-capturing lambda job with jobInput as its input on a background thread. The jobInput is converted to an immutable object and then passed to the job as argument.

On Android, it uses Executor service and on iOS, it uses background queue.

fun <T, V> dispatchOnNewBackgroundThread(jobInput: T, job: (T) -> V): Future<V>
dispatchOnWorker
Link copied to clipboard
common

Dispatches job with jobInput on the worker instance

fun <T, V> dispatchOnWorker(worker: Worker, jobInput: T, job: (T) -> V): Future<V>
equals
Link copied to clipboard
common
open operator override fun equals(other: Any?): Boolean
hashCode
Link copied to clipboard
common
open override fun hashCode(): Int
toString
Link copied to clipboard
common
open override fun toString(): String