Class Event<T>

java.lang.Object
io.avaje.inject.events.Event<T>
Type Parameters:
T - the type of the event object

public abstract class Event<T> extends Object
Allows the application to fire events of a particular type.

Beans fire events via an instance of the Event abstract class, which may be injected:

@Inject
Event<LoggedInEvent> loggedInEvent;

The fire() method accepts an event object:

public void login() {
  ...
  loggedInEvent.fire(new LoggedInEvent(user));
}

  • Field Details

  • Constructor Details

  • Method Details

    • fire

      public void fire(T event, String qualifier)
      Fires an event with the specified qualifier and notifies observers.
      Parameters:
      event - the event object
      qualifier - qualifier for this event
    • fireAsync

      public CompletionStage<T> fireAsync(T event, String qualifier)
      Fires an event with the specified qualifier and notifies asynchronous observers
      Parameters:
      event - the event object
      qualifier - the qualifier for this event
      Returns:
      a CompletableFuture allowing further pipeline composition on the asynchronous operation.
    • fire

      public void fire(T event)
      Fires an event and notifies observers with the qualifier set for this instance.
      Parameters:
      event - the event object
    • fireAsync

      public CompletionStage<T> fireAsync(T event)
      Fires an event to asynchronous observers with the qualifier set for this instance.
      Parameters:
      event - the event object
      Returns:
      a CompletionStage allowing further pipeline composition on the asynchronous operation.