Package-level declarations

User-facing (public) APIs for yafrl.

Types

Link copied to clipboard
class BindingSignal<A> : Signal<A>

Variant of Signal that can be setTo a new value.

Link copied to clipboard
open class BroadcastEvent<A>(node: Node<EventState<A>>) : Event<A>

A BroadcastEvent is an Event that can have new values emitted to it.

Link copied to clipboard
open class Event<out A>

An event is a value which is defined in instantaneous moments at time.

Link copied to clipboard
sealed interface EventState<out A>

Used to help represent Events as nodes.

Link copied to clipboard
fun interface MergeStrategy<A>

Strategy used to combine simultaneously occurring events within a frame when merging multiple Events.

Link copied to clipboard

Interface providing a context where Behaviors and Signals can be sampled.

Link copied to clipboard
open class Signal<out A>(val node: Node<A>)

A flow can be thought of as a combination of a io.github.yafrl.behaviors.Behavior and an Event.

Link copied to clipboard
interface SignalScope

Functions

Link copied to clipboard
inline fun <A> Signal<A>.asBehavior(): Behavior<A>

Utility to convert a Signal into a behavior whose values are interpreted as the piecewise function of the values of the Signal.

Link copied to clipboard
fun <A> Event<A>.debounced(window: Duration): Event<A>

Blocks occurrence of events until the window of time has passed, after which the latest event will be emitted.

Link copied to clipboard
inline fun <A> externalEvent(label: String? = null): BroadcastEvent<A>

Constructs a new external BroadcastEvent, which is intended to represent events external to the current Timeline. (See also externalSignal for the Signal variant of this).

Link copied to clipboard
inline fun <A> externalSignal(value: A, label: String? = null): BindingSignal<A>

Construct an external BindingSignal -- which is a Signal whose value can be updated to new values arbitrarily.

fun <A> externalSignal(value: A, kType: KType, label: String? = null): BindingSignal<A>
Link copied to clipboard

Construct a State<A> from a nested State<State<A>> by updating whenever either the inner or outer Signal updates.

Link copied to clipboard
inline fun <A> Event<A>.impulse(zero: @UnsafeVariance A): Behavior<A>

Builds a dirac impulse whose value is equal to the event values when the even has fired, and whole value is equal to zero otherwise

inline fun <A, B> Event<A>.impulse(zero: B, value: B): Behavior<B>

Builds a dirac impulse whose value is equal to value whenever the event fires, and zero otherwise.

Link copied to clipboard
fun <A> internalBindingState(value: Lazy<A>, label: String? = null): BindingSignal<A>

Internal version of externalSignal used for states which should be considered "internal" implementation details of the graph.

Link copied to clipboard

Creates a BroadcastEvent for internal implementation purposes.

Link copied to clipboard
fun <A, B> on(event: Event<B>, reducer: SampleScope.(A, B) -> A): Event<(A) -> A>
Link copied to clipboard
inline fun <A, B> onEvent(trigger: Event<A>, crossinline perform: suspend (A) -> B): Event<B>

onEvent acts similarly to map, however, rather than transforming each value of the input Event by a pure synchronous function, onEvent will launch a perform coroutine for every frame in which trigger has fired.

Link copied to clipboard
@JvmName(name = "plusFloat2")
operator fun Signal<Float2>.plus(other: Signal<Float2>): Signal<Float2>
@JvmName(name = "plusFloat23")
operator fun Signal<Float3>.plus(other: Signal<Float3>): Signal<Float3>
operator fun Signal<Float>.plus(other: Signal<Float>): Signal<Float>
Link copied to clipboard
inline fun <R> runYafrl(scope: CoroutineScope = CoroutineScope(Dispatchers.Default), timeTravel: Boolean = false, body: SampleScope.() -> R): R
Link copied to clipboard
inline fun <R> sample(body: SampleScope.() -> R): R

Introduces a context from which behaviors and states can be sampled.

Link copied to clipboard

Builds a Signal that updates with a list of all input states whenever any of the input states updates.

Link copied to clipboard
fun <A> signal(body: SignalScope.() -> A): Signal<A>

Monadic builder syntax for Signals, inspired by those formerly used by arrow-kt.

Link copied to clipboard
fun <A> Signal<Event<A>>.switch(): Event<A>

Constructs a flattened Event from a changing Signal of events over time.

Link copied to clipboard
fun <A> Event<A>.throttled(duration: Duration): Event<A>

Creates a modified Event that emits events at a frequency of at most duration.