Skip to content

NodeBindings

final class NodeBindings
Package: dev.joid.lib.ui.binding · Module: core · Source: NodeBindings.java

Signal bindings, followed suppliers, watches and queued events of one node or one UI.

Each Node and each UI owns one. It subscribes to its signals when the node is attached and unsubscribes when it is detached, reads its followed suppliers before each frame, and delivers the events of its InteractiveValues in the order of the changes, once the signals have settled. A custom node reaches it through getBindings() to create its own interactive values.

ReturnsSignatureSummary
NodeBindings(Object owner, EventBus eventBus, Supplier name, Consumer runner)Creates the bindings of owner, which fires its events on eventBus, is named by name in the warnings and runs each event listener through runner.

ReturnsSignatureSummary
voidopen()Opens a batch: signal notifications and queued events wait until the matching close().
voidclose()Closes a batch; at the outermost level, it delivers the queued events in their order.
ReturnsSignatureSummary
voidrelease(String property)Drops the binding or the followed supplier of property.
voidreleaseFollows()Drops every followed supplier and keeps the bindings to signals, as on the copy of a node.
ReturnsSignatureSummary
voidsubscribe(boolean loaded)Listens to the bound and watched signals, at the attachment of the node.
voidunsubscribe()Stops listening to the signals, at the detachment of the node.
Tfollow(String property, Supplier supplier, Consumer applier)Applies the value of supplier to property now and again before each frame when it changes, then returns the owner.
thisbind(String property, Signal signal, Consumer applier, Function<M,V> writer) fluentBinds property to signal in both directions, then returns the owner: applier receives each value of the signal except null, and writer turns the value of the node into the value to write back.
TbindNullable(String property, Signal signal, Consumer applier, Function<M,V> writer)Binds property like bind(...), and passes null values to applier too.
voidsync(String property, Object value)Writes value back to the signal bound to property.
voidbatch(Runnable runnable)Runs runnable inside a batch.
Twatch(Signal<?> signal, BooleanSupplier condition, Runnable action)Runs action after each change of signal while condition is true and the node is attached, then returns the owner.
voidpull()Reads every followed supplier and applies the values that changed.
ReturnsSignatureSummary
booleanisBound(String property)If true, property is bound to a writable signal.
booleanisFollowed(String property)If true, property follows a supplier.
booleanisSubscribed()If true, the node is attached and listens to its signals.
ReturnsSignatureSummary
Tstart(String property, V value, Consumer applier)Drops the binding of property, applies value through applier, then returns the owner.
voidexternal(Runnable runnable)Runs runnable as a change that comes from outside the bound signal, so its write back reaches the signal even when the node has not seen its last value yet.
voidsee(String property)Records the current value of the signal bound to property as seen by the node.
voidtrack(InteractiveValue<?> value)Registers an interactive value, so input dispatches mark and commit it.
voidmark()Marks every interactive value at the start of an input dispatch.
voidcommit()Commits every interactive value at the end of an input dispatch.
Tlisten(EventType type, EventListener listener)Adds listener for the events of type, then returns the owner.
thisfire(EventType<?> type, Supplier event) fluentCreates the event with event and fires it, and returns it; it returns null and creates nothing when no listener waits for this type.
ReturnsSignatureSummary
EfireSubscribed(EventType<?> type, Supplier event)Fires like fire(...) while the node is attached, after the signal notifications in progress; it returns null when the node is detached.

NodeBindings(Object owner, EventBus eventBus, Supplier<String> name, Consumer<Runnable> runner)

Creates the bindings of owner, which fires its events on eventBus, is named by name in the warnings and runs each event listener through runner.

void open()

Opens a batch: signal notifications and queued events wait until the matching close().

void close()

Closes a batch; at the outermost level, it delivers the queued events in their order.

void release(String property)

Drops the binding or the followed supplier of property.

void releaseFollows()

Drops every followed supplier and keeps the bindings to signals, as on the copy of a node.

void subscribe(boolean loaded)

Listens to the bound and watched signals, at the attachment of the node. A bound property takes the value its signal reached while the node was detached; when loaded is true, a watch whose signal changed meanwhile runs once.

void unsubscribe()

Stops listening to the signals, at the detachment of the node.

<T, V> T follow(String property, Supplier<V> supplier, Consumer<V> applier)

Applies the value of supplier to property now and again before each frame when it changes, then returns the owner. A constant ComputedSignal applies once and is not kept.

this bind(String property, Signal<V> signal, Consumer<V> applier, Function<M,V> writer) fluent

Binds property to signal in both directions, then returns the owner: applier receives each value of the signal except null, and writer turns the value of the node into the value to write back. Throws an IllegalArgumentException when the signal is read-only.

<T, V, M> T bindNullable(String property, Signal<V> signal, Consumer<V> applier, Function<M,V> writer)

Throws:

  • IllegalArgumentException: The … of … is changed by the user, so it cannot follow …, which cannot be written: pass a writable Signal, or its value as a start value

Binds property like bind(...), and passes null values to applier too.

void sync(String property, Object value)

Writes value back to the signal bound to property. When bound controls keep correcting each other’s value, it stops after 16 corrections, restores the value of the signal and prints a dev warning.

void batch(Runnable runnable)

Runs runnable inside a batch.

<T> T watch(Signal<?> signal, BooleanSupplier condition, Runnable action)

Runs action after each change of signal while condition is true and the node is attached, then returns the owner.

void pull()

Reads every followed supplier and applies the values that changed. When an applier throws, JOID prints a warning and the property keeps its previous value.

boolean isBound(String property)

If true, property is bound to a writable signal.

boolean isFollowed(String property)

If true, property follows a supplier.

boolean isSubscribed()

If true, the node is attached and listens to its signals.

<T, V> T start(String property, V value, Consumer<V> applier)

Drops the binding of property, applies value through applier, then returns the owner.

void external(Runnable runnable)

Runs runnable as a change that comes from outside the bound signal, so its write back reaches the signal even when the node has not seen its last value yet.

void see(String property)

Records the current value of the signal bound to property as seen by the node.

void track(InteractiveValue<?> value)

Registers an interactive value, so input dispatches mark and commit it.

void mark()

Marks every interactive value at the start of an input dispatch.

void commit()

Commits every interactive value at the end of an input dispatch.

<T> T listen(EventType<?> type, EventListener<?> listener)

Adds listener for the events of type, then returns the owner.

this fire(EventType<?> type, Supplier<E> event) fluent

Creates the event with event and fires it, and returns it; it returns null and creates nothing when no listener waits for this type. A cancellable or consumable event fires at once; another one waits for the end of the batch in progress.

<E extends Event> E fireSubscribed(EventType<?> type, Supplier<E> event)

Fires like fire(...) while the node is attached, after the signal notifications in progress; it returns null when the node is detached.


fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses

Report a problem with this page