Data

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

A data element characterized by its meta

Types

Companion
Link copied to clipboard
common
object Companion

Functions

async
Link copied to clipboard
common
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.

reset
Link copied to clipboard
common
abstract fun reset()

Reset the computation

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

Properties

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

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

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

Meta for the data

type
Link copied to clipboard
common
abstract val type: KType

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

Inheritors

StaticData
Link copied to clipboard
NamedData
Link copied to clipboard

Extensions

combine
Link copied to clipboard
common
inline fun <T1 : Any, T2 : Any, R : Any> Data<T1>.combine(other: Data<T2>, coroutineContext: CoroutineContext = EmptyCoroutineContext, meta: Meta = this.meta, crossinline block: suspend (T1, T2) -> R): Data<R>

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

map
Link copied to clipboard
common
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).

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