Class SignalOutput<T>

java.lang.Object
com.vaadin.flow.component.trigger.AbstractOutput<T>
com.vaadin.flow.component.trigger.SignalOutput<T>
Type Parameters:
T - the runtime type of the produced value
All Implemented Interfaces:
Output<T>, Serializable

public class SignalOutput<T> extends AbstractOutput<T>
Output backed by a server-side Signal. The signal's current value is snapshotted into the client config at each emit; a host-scoped effect subscribes to the signal so that every change re-emits the snapshot.

Snapshot semantics: actions read the latest value at trigger fire time. This is a value reader, not a graph builder — composing computed outputs remains the signal layer's job (use Signal.cached(com.vaadin.flow.signals.Signal<T>)).


 ValueSignal<String> locale = ...;
 new ClickTrigger(button).triggers(
         new ClipboardCopyAction(new SignalOutput<>(String.class, locale)));
 
The effect that wires the re-emit is created lazily on the first buildClientConfig call against an attached host, and is cleaned up automatically by ElementEffect when the host detaches.
See Also:
  • Field Details

  • Constructor Details

    • SignalOutput

      public SignalOutput(Class<T> valueType, Signal<T> signal)
      Creates a signal-backed output.
      Parameters:
      valueType - runtime type of the produced value, not null
      signal - the source signal, not null
  • Method Details

    • of

      public static <T> SignalOutput<T> of(ValueSignal<T> signal, Class<T> valueType)
      Convenience for the common case: pair a ValueSignal with an output of the same value type.
      Type Parameters:
      T - the value type
      Parameters:
      signal - the source signal, not null
      valueType - runtime type, not null
      Returns:
      a new SignalOutput
    • getSignal

      public Signal<T> getSignal()
      Returns:
      the source signal
    • buildClientConfig

      public tools.jackson.databind.node.ObjectNode buildClientConfig(ConfigContext context)
      Description copied from class: AbstractOutput
      Produces the JSON configuration this output sends to the client. Default is an empty object; override to add type-specific options.

      Subclasses encode element references by calling ConfigContext.referenceElement(com.vaadin.flow.dom.Element). Public so the internal framework can read the config without reflection; subclasses just override.

      Overrides:
      buildClientConfig in class AbstractOutput<T>
      Parameters:
      context - the resolver for referenced elements, not null
      Returns:
      a Jackson ObjectNode, never null