Interface BetterModelEventBus


public interface BetterModelEventBus
A central event bus for handling model-related events.

This interface allows subscribing to and publishing ModelEvents. It serves as a decoupling mechanism between different parts of the engine.

Since:
2.0.0
  • Method Details

    • subscribe

      @NotNull <T extends ModelEvent> @NotNull ModelEventListener subscribe(@NotNull @NotNull ModelEventApplication application, @NotNull @NotNull Class<T> eventClass, @NotNull @NotNull Consumer<T> consumer)
      Subscribes a consumer to a specific event type.
      Type Parameters:
      T - the type of the event
      Parameters:
      application - the application that subscribes to the event
      eventClass - the class of the event to subscribe to
      consumer - the consumer to handle the event
      Returns:
      a listener handle that can be used to unregister the subscription
      Since:
      2.0.0
    • call

      @NotNull <T extends ModelEvent> @NotNull BetterModelEventBus.Result call(@NotNull @NotNull Class<? extends T> eventClass, @NotNull @NotNull Supplier<T> eventSupplier)
      Publishes an event to all registered subscribers.

      The event is created lazily using the provided supplier if there are subscribers.

      Type Parameters:
      T - the type of the event
      Parameters:
      eventClass - the class of the event
      eventSupplier - a supplier that creates the event
      Returns:
      the result of the event call
      Since:
      2.0.0
    • call

      @NotNull default @NotNull BetterModelEventBus.Result call(@NotNull @NotNull ModelEvent event)
      Publishes an event to all registered subscribers.
      Parameters:
      event - the event to publish
      Returns:
      the result of the event call
      Since:
      2.0.0