Class SignalInput<T>
- Type Parameters:
T- the runtime type of the value produced
- All Implemented Interfaces:
Serializable
Signal at the moment a
trigger fires.
When this input is rendered into a trigger's handler — at the
Trigger.triggers(Action...) call site — a component-scoped
effect is installed once. It mirrors the signal value to a uniquely-named
JavaScript property on the owner component's element via
Element.executeJs(java.lang.String, java.lang.Object...); every subsequent signal change pushes the new
value to the client. The trigger reads that property at fire time, so the
value seen reflects whatever the signal held the last time it propagated.
Constructing a SignalInput has no side effects — no effect is
installed and no JS is queued until the input is wired into a trigger.
The owner drives the lifecycle: while it is detached the effect is
suspended (and the property on the client retains the last pushed value); on
re-attach the effect re-emits the current value.
ValueSignal<String> textSignal = new ValueSignal<>("Hello");
new ClickTrigger(copyButton).triggers(new WriteToClipboardAction(
new SignalInput<>(this, textSignal), null));
textSignal.set("Goodbye");
// Clicking the button after the set copies "Goodbye".
For internal use only. May be renamed or removed in a future release.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSignalInput(Component owner, Signal<T> signal) Creates a signal-backed input. -
Method Summary
Modifier and TypeMethodDescriptionprotected JsFunctionBuilds theJsFunctionthat yields this input's value when called.
-
Constructor Details
-
SignalInput
Creates a signal-backed input. No effect is installed until the input is actually rendered into a trigger handler.- Parameters:
owner- the component whose lifecycle bounds the signal effect and whose element holds the mirrored value; notnullsignal- the signal whose value should be read at fire time, notnull
-
-
Method Details
-
toJs
Description copied from class:Action.InputBuilds theJsFunctionthat yields this input's value when called. The function may takeeventas a runtime argument (declared by the subclass viaJsFunction.withArguments(String...)); inputs that don't needeventsimply omit the declaration and ignore the argument the caller passes.- Specified by:
toJsin classAction.Input<T>- Parameters:
trigger- the surrounding trigger this render is for, notnull- Returns:
- the input's JS function, not
null
-