Timeline

class Timeline(val scope: CoroutineScope, timeTravelEnabled: Boolean, debugLogging: Boolean, eventLogger: EventLogger, val graph: Graph, initTimeTravel: (Timeline) -> TimeTravelDebugger, lazy: Boolean, initClock: (Signal<Boolean>) -> Event<Duration>) : SynchronizedObject, EventLogger(source)

Simple implementation of a push-pull FRP system using a graph of nodes.

Changes are propagated by marking child nodes as dirty when a parent value changes.

Dirty values are recomputed lazily upon request.

Constructors

Link copied to clipboard
constructor(scope: CoroutineScope, timeTravelEnabled: Boolean, debugLogging: Boolean, eventLogger: EventLogger, graph: Graph, initTimeTravel: (Timeline) -> TimeTravelDebugger, lazy: Boolean, initClock: (Signal<Boolean>) -> Event<Duration>)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard

Keep track of any external (or "input") nodes to the system so they can be used for testing / debugging.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val scope: CoroutineScope
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun <A> createCombinedNode(parentNodes: List<Node<Any?>>, combine: (List<Any?>) -> A, onNextFrame: (Node<A>) -> Unit? = null): Node<A>

Creates a node that updates whenever any of its parentNodes updates.

Link copied to clipboard
fun <A, B> createFoldNode(initialValue: A, eventNode: Node<EventState<B>>, reducer: SampleScope.(A, B) -> A): Node<A>

Creates a node whose value updates by the action specified by the reducer.

Link copied to clipboard
fun <A> createNode(value: Lazy<A>, onUpdate: (Node<A>) -> A = { it -> it.rawValue }, onNextFrame: (Node<A>) -> Unit? = null, onRollback: (node: Node<A>, frame: Long) -> Unit? = null, label: String? = null): Node<A>

Creates a new node without any parent / input nodes.

Link copied to clipboard
open override fun logEvent(event: ExternalEvent)

Send an event to the log.

Link copied to clipboard
Link copied to clipboard
open override fun reportEvents(): List<ExternalEvent>

Return the list of all currently logged events in-order.

Link copied to clipboard
fun updateNodeValue(node: Node<Any?>, newValue: Any?, internal: Boolean = false, resetting: Boolean = false)

Updates the value of the node in the Timeline, yielding a new frame so long as this is not an internal update.