Data

@DfId(id = "data")
interface Data<out T> : Goal<T> , MetaRepr

A data element characterized by its meta

Inheritors

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
abstract val deferred: Deferred<T>?

Returns current running coroutine if the goal is started. Null if the computation is not started.

Link copied to clipboard
abstract val dependencies: Collection<Goal<*>>
Link copied to clipboard
Link copied to clipboard
abstract val meta: Meta

Meta for the data

Link copied to clipboard
abstract val type: KType

Type marker for the data. The type is known before the calculation takes place so it could be checked.

Functions

Link copied to clipboard
abstract fun async(coroutineScope: CoroutineScope): Deferred<T>

Get ongoing computation or start a new one. Does not guarantee thread safety. In case of multi-thread access, could create orphan computations.

Link copied to clipboard
suspend fun <T> Goal<T>.await(): T
Link copied to clipboard
suspend fun <T : Any> Data<T>.awaitWithMeta(): ValueWithMeta<T>
Link copied to clipboard
inline fun <T1 : Any, T2 : Any, R : Any> Data<T1>.combine(other: Data<T2>, coroutineContext: CoroutineContext = EmptyCoroutineContext, meta: Meta = this.meta, crossinline block: suspend (left: T1, right: T2) -> R): Data<R>

Combine this data with the other data using block. See Data::map for other details

Link copied to clipboard
fun Goal<*>.launch(coroutineScope: CoroutineScope): Job
Link copied to clipboard
inline fun <T : Any, R : Any> Data<T>.map(coroutineContext: CoroutineContext = EmptyCoroutineContext, meta: Meta = this.meta, crossinline block: suspend (T) -> R): Data<R>

Lazily transform this data to another data. By convention block should not use external data (be pure).

Link copied to clipboard
fun <T : Any> Data<T>.named(name: Name): NamedData<T>
Link copied to clipboard
abstract fun reset()

Reset the computation

Link copied to clipboard
open override fun toMeta(): Meta