java.lang.Object
me.stringdotjar.flixelgdx.util.signal.FlixelSignal<T>

public class FlixelSignal<T> extends Object
Utility class for creating objects that can execute multiple callbacks when it is dispatched (or triggered).
  • Constructor Details

    • FlixelSignal

      public FlixelSignal()
  • Method Details

    • add

      public void add(FlixelSignal.SignalHandler<T> callback)
      Adds a new callback to this signal to be executed upon dispatch() being called.
      Parameters:
      callback - The new callback to add to the signal, with the type intended to be a Java record.
    • addOnce

      public void addOnce(FlixelSignal.SignalHandler<T> callback)
      Adds a temporary callback that only gets ran once. When dispatch() is executed, the temporary callback is removed.
      Parameters:
      callback - The new temporary callback to add, with the type intended to be a Java record.
    • remove

      public void remove(FlixelSignal.SignalHandler<T> callback)
      Removes a specific callback from this signal.
      Parameters:
      callback - The callback to remove.
    • clear

      public void clear()
      Removes all callbacks from this signal.
    • dispatch

      public void dispatch()
      Triggers this signal and executes all callbacks.
    • dispatch

      public void dispatch(T data)
      Triggers this signal and executes all callbacks.
      Parameters:
      data - The parameters that this signal takes.