Class Effect

java.lang.Object
com.vaadin.signals.impl.Effect

public class Effect extends Object
Applies a side effect based on signal value changes. An effect is a callback that is initially run when the effect is created, and subsequently run again whenever any dependency changes. Dependencies are automatically registered for all signals that are read from the callback. The callback is run again whenever there's a change to any dependency. Dependencies are always updated based the signals read during the most recent invocation.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Effect(Runnable action)
    Creates a signal effect with the given action and the default dispatcher.
    Effect(Runnable action, Executor dispatcher)
    Creates a signal effect with the given action and a custom dispatcher.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Disposes this effect by unregistering all current dependencies and preventing the action from running again.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Effect

      public Effect(Runnable action)
      Creates a signal effect with the given action and the default dispatcher. The action is run when the effect is created and is subsequently run again whenever there's a change to any signal value that was read during the last invocation.
      Parameters:
      action - the action to use, not null
      See Also:
    • Effect

      public Effect(Runnable action, Executor dispatcher)
      Creates a signal effect with the given action and a custom dispatcher. The action is run when the effect is created and is subsequently run again whenever there's a change to any signal value that was read during the last invocation. The dispatcher can be used to make sure changes are evaluated asynchronously or with some specific context available. The action itself needs to be synchronous to be able to track changes.
      Parameters:
      action - the action to use, not null
      dispatcher - the dispatcher to use when handling changes, not null
  • Method Details

    • dispose

      public void dispose()
      Disposes this effect by unregistering all current dependencies and preventing the action from running again.