Type Parameters:
S - the type of subscribers that can register to the event bus
E - the type of events that can be posted to the event bus

public interface EventBus<S,E>
The EventBus interface defines the contract for an event bus system that allows objects to register as subscribers, unregister from receiving events, and post events to all registered subscribers.
  • Method Summary

    Modifier and Type
    Method
    Description
    Retrieves all currently registered subscriber objects.
    void
    post(E event)
    Posts the specified event to all registered subscribers Each subscriber that is interested in the event will receive it.
    void
    register(S subscriber)
    Registers the specified subscriber object to the event bus After registration, the subscriber will receive events posted to the bus.
    void
    unregister(S subscriber)
    Unregisters the specified subscriber object from the event bus After unregistration, the subscriber will no longer receive events posted to the bus.
  • Method Details

    • register

      void register(S subscriber)
      Registers the specified subscriber object to the event bus After registration, the subscriber will receive events posted to the bus.
      Parameters:
      subscriber - the subscriber object to register
    • unregister

      void unregister(S subscriber)
      Unregisters the specified subscriber object from the event bus After unregistration, the subscriber will no longer receive events posted to the bus.
      Parameters:
      subscriber - the subscriber object to unregister
    • post

      void post(E event)
      Posts the specified event to all registered subscribers Each subscriber that is interested in the event will receive it.
      Parameters:
      event - the event to post
    • getSubscribers

      Collection<S> getSubscribers()
      Retrieves all currently registered subscriber objects.
      Returns:
      a collection of all registered subscriber objects