Documentation / dataflow-async / com.femastudios.dataflow.async / WorkContext
Go to reference

WorkContext

abstract class WorkContext

This class is the receiver of any attribute computation. It provides a way to set the attribute state to something other than Loaded.

Internally it works by throwing a FlowException. In Kotlin, use the methods throwError or throwNotLoaded. In java use by throwing the result of notLoadedException or errorException.

There are also unsafe variants that allow you to pass a state of any type. This is needed because this class cannot have its own type parameter due to limitations of the Kotlin type-inference system. Adding a type parameter to this class would result in the need to specify it explicitly at every transformations, and it's not acceptable.

See also online doc

Properties

onRetry

The default onRetry function for error statuses

abstract val onRetry: (() -> Unit)?

Functions

equals

open fun equals(other: Any?): Nothing

errorException

Creates and returns a FlowException that contains an Error state with the provided parameters.

fun errorException(displayableMessage: String? = null, displayableDescription: String? = null): FlowException

Creates and returns a FlowException that contains the provided error (notice that it must be of Nothing in order to guarantee type safety).

fun errorException(error: Error<Nothing>): FlowException

hashCode

open fun hashCode(): Nothing

notLoadedException

Creates and returns a FlowException that contains the provided data (notice that it must be of Nothing in order to guarantee type safety).

fun notLoadedException(data: NotLoaded<Nothing>): FlowException

throwError

Throws a FlowException that contains an Error state with the provided parameters.

fun throwError(displayableMessage: String? = null, displayableDescription: String? = null): Nothing

Throws a FlowException that contains the provided error (notice that it must be of Nothing in order to guarantee type safety).

fun throwError(error: Error<Nothing>): Nothing

throwNotLoaded

Throws a FlowException that contains the provided data (notice that it must be of Nothing in order to guarantee type safety).

fun throwNotLoaded(data: NotLoaded<Nothing>): Nothing

throwUnsafeError

Like throwError, but accepts an error with anything as type parameter. This function cannot guarantee type safety, but you can use it if you're absolutely sure of what you're doing.

fun throwUnsafeError(error: Error<*>): Nothing

throwUnsafeNotLoaded

Like throwNotLoaded, but accepts a data with anything as type parameter. This function cannot guarantee type safety, but you can use it if you're absolutely sure of what you're doing.

fun throwUnsafeNotLoaded(data: NotLoaded<*>): Nothing

toString

open fun toString(): Nothing

unsafeErrorException

Like errorException, but accepts an error with anything as type parameter. This function cannot guarantee type safety, but you can use it if you're absolutely sure of what you're doing.

fun unsafeErrorException(error: Error<*>): FlowException

unsafeNotLoadedException

Like notLoadedException, but accepts a data with anything as type parameter. This function cannot guarantee type safety, but you can use it if you're absolutely sure of what you're doing.

fun unsafeNotLoadedException(data: NotLoaded<*>): FlowException