ActiveDataTree

class ActiveDataTree<T : Any>(dataType: KType) : DataTree<T> , DataSetBuilder<T> , ActiveDataSet<T>

A mutable DataTree.Companion.active. It

Constructors

ActiveDataTree
Link copied to clipboard
common
fun ActiveDataTree(dataType: KType)

Functions

emit
Link copied to clipboard
common
open suspend override fun emit(name: Name, data: Data<T>?)
open suspend fun emit(name: Name, dataSet: DataSet<T>)

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

flowData
Link copied to clipboard
common
open override fun flowData(): Flow<NamedData<T>>

Traverse this provider or its child. The order is not guaranteed.

getData
Link copied to clipboard
common
open suspend override fun getData(name: Name): Data<T>?

Get data with given name.

items
Link copied to clipboard
common
open suspend override fun items(): Map<NameToken, DataTreeItem<T>>

Children items of this DataTree provided asynchronously

listTop
Link copied to clipboard
common
open suspend override fun listTop(prefix: Name): List<Name>

Get a snapshot of names of top level children of given node. Empty if node does not exist or is a leaf.

put
Link copied to clipboard
common
open infix suspend fun String.put(block: suspend DataSetBuilder<T>.() -> Unit)

Build and append node

open infix suspend fun String.put(dataSet: DataSet<T>)

Append node

open infix suspend fun String.put(data: Data<T>)

Append data to node

remove
Link copied to clipboard
common
open suspend override fun remove(name: Name)

Remove all data items starting with name

setAndObserve
Link copied to clipboard
common
fun CoroutineScope.setAndObserve(name: Name, dataSet: DataSet<T>): Job

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

Properties

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

The minimal common ancestor to all data in the node

updates
Link copied to clipboard
common
open override val updates: Flow<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.

Extensions

emit
Link copied to clipboard
common
inline suspend fun <T : Any> ActiveDataTree<T>.emit(name: Name, noinline block: suspend ActiveDataTree<T>.() -> Unit)
inline suspend fun <T : Any> ActiveDataTree<T>.emit(name: String, noinline block: suspend ActiveDataTree<T>.() -> Unit)