DataTreeBuilder

class DataTreeBuilder<T : Any>(val dataType: KType, coroutineContext: CoroutineContext) : DataTree<T> , DataSourceBuilder<T>

A mutable DataTree that propagates updates

Constructors

Link copied to clipboard
constructor(dataType: KType, coroutineContext: CoroutineContext)

Properties

Link copied to clipboard
Link copied to clipboard
open override val dataType: KType

The minimal common ancestor to all data in the node

Link copied to clipboard
open override val items: Map<NameToken, DataTreeItem<T>>

Top-level children items of this DataTree

Link copied to clipboard
open override val meta: Meta

Meta-data associated with this node. If no meta is provided, returns Meta.EMPTY.

Link copied to clipboard
val CoroutineScope.monitor: CoroutineMonitor?
Link copied to clipboard
open override val updates: MutableSharedFlow<Name>

A flow of updated item names. Updates are propagated in a form of Flow of names of updated nodes. Those can include new data items and replacement of existing ones. The replaced items could update existing data content and replace it completely, so they should be pulled again.

Link copied to clipboard
val <T : Any> DataSet<T>.updates: Flow<Name>
Link copied to clipboard

Functions

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun <T : Any> DataSet<T>.branch(branchName: String): DataSet<T>
fun <T : Any> DataTree<T>.branch(branchName: String): DataTree<T>

fun <T : Any> DataSet<T>.branch(branchName: Name): DataSet<T>

Get a subset of data starting with a given branchName

fun <T : Any> DataTree<T>.branch(branchName: Name): DataTree<T>

Get a branch of this DataTree with a given branchName. The difference from similar method for DataSet is that internal logic is more simple and the return value is a DataTree

Link copied to clipboard
open fun close()

Stop generating updates from this DataSource

Link copied to clipboard
suspend fun <T : Any> DataSet<T>.computeAndJoinAll()
Link copied to clipboard
open override fun data(name: Name, data: Data<T>?)
Link copied to clipboard
fun <T : Any> DataSetBuilder<T>.data(name: String, value: Data<T>)
Link copied to clipboard
inline fun <T : Any> DataSourceBuilder<T>.emit(name: String, parent: CoroutineScope, noinline block: DataSourceBuilder<T>.() -> Unit)
inline fun <T : Any> DataSourceBuilder<T>.emit(name: Name, parent: CoroutineScope, noinline block: DataSourceBuilder<T>.() -> Unit)
Link copied to clipboard
fun <T : Any> DataSet<T>.filter(predicate: (Name, Meta) -> Boolean): DataSource<T>

A stateless filtered DataSet

Link copied to clipboard
inline fun <R : Any> DataSet<*>.filterByType(noinline predicate: (name: Name, meta: Meta) -> Boolean = { _, _ -> true }): DataSet<R>

Select a single datum of the appropriate type

fun <R : Any> DataSet<*>.filterByType(type: KType, predicate: (name: Name, meta: Meta) -> Boolean = { _, _ -> true }): DataSource<R>

Select all data matching given type and filters. Does not modify paths

Link copied to clipboard
inline fun <T : Any, R : Any> DataSet<T>.foldToData(initial: R, coroutineContext: CoroutineContext = EmptyCoroutineContext, meta: Meta = Meta.EMPTY, crossinline block: suspend (result: R, data: NamedValueWithMeta<T>) -> R): Data<R>
Link copied to clipboard
inline fun <T : Any> DataSet<T>.forEach(block: (NamedData<T>) -> Unit)
Link copied to clipboard
open operator override fun get(name: Name): Data<T>?

Get data with given name.

Link copied to clipboard
operator fun <T : Any> DataSet<T>.get(name: String): Data<T>?
Link copied to clipboard
inline fun <R : Any> DataSet<*>.getByType(name: String): NamedData<R>?
inline fun <R : Any> DataSet<*>.getByType(name: Name): NamedData<R>?

fun <R : Any> DataSet<*>.getByType(type: KType, name: Name): NamedData<R>?

Select a single datum if it is present and of given type

Link copied to clipboard
tailrec fun <T : Any> DataTree<T>.getItem(name: Name): DataTreeItem<T>?

Get a DataTreeItem with given name or null if the item does not exist

Link copied to clipboard
open operator override fun iterator(): Iterator<NamedData<T>>

Traverse this DataSet returning named data instances. The order is not guaranteed.

Link copied to clipboard
fun <T : Any> DataTree<T>.listChildren(prefix: Name): List<Name>
Link copied to clipboard
inline suspend fun <T : Any, R : Any> DataSet<T>.map(coroutineContext: CoroutineContext = EmptyCoroutineContext, noinline metaTransform: MutableMeta.() -> Unit = {}, noinline block: suspend (NamedValueWithMeta<T>) -> R): DataTree<R>
suspend fun <T : Any, R : Any> DataSet<T>.map(outputType: KType, coroutineContext: CoroutineContext = EmptyCoroutineContext, metaTransform: MutableMeta.() -> Unit = {}, block: suspend (NamedValueWithMeta<T>) -> R): DataTree<R>
Link copied to clipboard
open override fun meta(name: Name, meta: Meta)

Set meta for the given node

Link copied to clipboard
fun <T : Any> DataSetBuilder<T>.meta(mutableMeta: MutableMeta.() -> Unit)
fun <T : Any> DataSetBuilder<T>.meta(value: Meta)

Define meta in this DataSet

Link copied to clipboard
open fun node(name: Name, dataSet: DataSet<T>)

Set a current state of given dataSet into a branch name. Does not propagate updates

Link copied to clipboard
inline fun <T : Any> DataSetBuilder<T>.node(name: String, crossinline block: DataSetBuilder<T>.() -> Unit)
fun <T : Any> DataSetBuilder<T>.node(name: String, set: DataSet<T>)
inline fun <T : Any> DataSetBuilder<T>.node(name: Name, crossinline block: DataSetBuilder<T>.() -> Unit)
Link copied to clipboard

Update data with given node data and meta with node meta.

Link copied to clipboard
inline fun <T : Any> DataSetBuilder<T>.produce(name: String, meta: Meta = Meta.EMPTY, noinline producer: suspend () -> T)

Produce lazy Data and emit it into the DataSetBuilder

inline fun <T : Any> DataSetBuilder<T>.produce(name: Name, meta: Meta = Meta.EMPTY, noinline producer: suspend () -> T)
Link copied to clipboard
inline fun <T : Any, R : Any> DataSet<T>.reduceToData(coroutineContext: CoroutineContext = EmptyCoroutineContext, meta: Meta = Meta.EMPTY, crossinline transformation: suspend (Iterable<NamedValueWithMeta<T>>) -> R): Data<R>
Link copied to clipboard
open override fun remove(name: Name)

Remove all data items starting with name

Link copied to clipboard
suspend fun <T : Any> DataSet<T>.rootData(): Data<T>?
Link copied to clipboard
fun <T : Any> DataSet<T>.seal(): DataTree<T>
Link copied to clipboard
fun <T : Any> DataSetBuilder<T>.set(value: NamedData<T>)
Link copied to clipboard
fun <T : Any> CoroutineScope.setAndWatch(name: Name, dataSet: DataSet<T>): Job

Copy given data set and mirror its changes to this DataTreeBuilder in this@setAndObserve. Returns an update Job

Link copied to clipboard
fun <T : Any> DataSet<T>.single(): NamedData<T>

Return a single Data in this DataSet. Throw error if it is not single.

Link copied to clipboard
fun <T : Any> DataSet<T>.startAll(coroutineScope: CoroutineScope): Job

Start computation for all goals in data node and return a job for the whole node

Link copied to clipboard
inline fun <T : Any> DataSetBuilder<T>.static(name: String, data: T, mutableMeta: MutableMeta.() -> Unit)
inline fun <T : Any> DataSetBuilder<T>.static(name: Name, data: T, meta: Meta = Meta.EMPTY)

inline fun <T : Any> DataSetBuilder<T>.static(name: String, data: T, meta: Meta = Meta.EMPTY)

Emit a static data with the fixed value

Link copied to clipboard
fun DataSet<*>.toMeta(): Meta
Link copied to clipboard

A Sequence of all children including nodes

Link copied to clipboard
fun <T : Any> DataSet<T>.withNamePrefix(prefix: Name): DataSet<T>

Generate a wrapper data set with a given name prefix appended to all names