JobManager

class JobManager<K : Any>

An entity that manages running jobs. Used with jobManagerPlugin and manageJobs. Will cancel and remove all jobs if the parent pro.respawn.flowmvi.api.Store is closed

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

Returns a read-only view of the currently active jobs.

Link copied to clipboard

Returns true if this manager has any active jobs, false otherwise.

Functions

Link copied to clipboard
fun cancel(key: K): Job?

Cancel a job with the specified key

Link copied to clipboard
fun cancelAll()

Cancels all jobs without suspending

Link copied to clipboard
suspend fun cancelAndJoin(key: K): Job?

Cancel and join a job for key if it is present

Link copied to clipboard
suspend fun cancelAndJoinAll()

Cancels all jobs in parallel and then joins them all sequentially

Link copied to clipboard
operator fun get(key: K): Job?

Get a job for the specified key.

Link copied to clipboard
operator fun invoke(key: K, job: Job)

Alias for set and put.

Link copied to clipboard
suspend fun join(key: K): Job?

Join the job for key if it is present.

Link copied to clipboard
suspend fun joinAll()

Joins all jobs sequentially

suspend fun joinAll(vararg keys: K)

Joins all jobs specified in keys in the declaration order

Link copied to clipboard
fun put(key: K, job: Job)

Put a job into the container and throw IllegalArgumentException if the job with the same key is already running.

Link copied to clipboard
fun putAll(vararg jobs: Pair<K, Job>)

Put all jobs into the storage.

Link copied to clipboard
suspend fun putOrReplace(key: K, job: Job): Job?

Put a job into the container and call Job.cancelAndJoin if one already exists there.

Link copied to clipboard
operator fun set(key: K, value: Job)

Alias for put. Will throw if a job with the same key already exists.

Link copied to clipboard
fun start(key: K): Job?

Start the job with key if it is present.