State
An interface shows values that change: a total, a list, a setting, a status that arrives from a server.
In JOID, init() builds the tree once per opening, and the values that change live in signals.
This chapter builds on signals: it computes values from them, rebuilds the nodes that come and go, keeps values that several UIs or several launches share, and changes them over time.
Derived values
Section titled “Derived values”A derived value is computed once from other signals, and behaves like a signal of its own.
final ComputedSignal<Integer> total = Signal.from(() -> price.get() * quantity.get());Read Derived values to learn map, Signal.from, batch, and how to run your own code when a value changes.
Rebuilding the tree
Section titled “Rebuilding the tree”When a change adds or removes nodes, a node builds its children again; when the data is not there yet, a node waits behind a placeholder.
.watch(this.items, WatchProperty.CLEAR_CHILDREN, WatchProperty.BODY)Read Rebuilding the tree to learn watch, wait and skeletons.
Stores and remembered properties
Section titled “Stores and remembered properties”A store shares values between UIs and can keep them on disk; a remembered property keeps one field of a UI across launches.
final SettingsStore settings = super.useStore(SettingsStore.class, SettingsStore::new);Read Stores and remembered properties to learn where a value should live and how to write a store.
Tasks and background updates
Section titled “Tasks and background updates”A task runs your code after a delay or on a period, and a signal set from another thread takes its value at the next frame.
final IntegerSignal seconds = new IntegerSignal(0);Task.create(1000L).every(1000L).onRun(event -> seconds.increment()).attach(this);Read Tasks and background updates to learn Task and how a worker thread hands its results to the interface.
