Interface OwnedEventBus<O,​E,​S extends OwnedSubscriber<O,​? extends E>>

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void register​(@NonNull O owner, @NonNull java.lang.Object listener)
      Registers events for the given listener.
      <T extends E,​U extends OwnedSubscriber<O,​T>>
      @NonNull U
      subscribe​(@NonNull O owner, @NonNull java.lang.Class<T> eventClass, @NonNull java.util.function.Consumer<T> consumer)
      Subscribes to the given event see Subscriber.
      <T extends E,​U extends OwnedSubscriber<O,​T>>
      @NonNull U
      subscribe​(@NonNull O owner, @NonNull java.lang.Class<T> eventClass, @NonNull java.util.function.Consumer<T> consumer, @NonNull PostOrder postOrder)
      Subscribes to the given event see Subscriber.
      <T extends E>
      @NonNull java.util.Set<? extends OwnedSubscriber<O,​T>>
      subscribers​(@NonNull java.lang.Class<T> eventClass)
      Gets the subscriptions for the given event class.
      void unregisterAll​(@NonNull O owner)
      Unregisters all events from a given owner.
    • Method Detail

      • subscribe

        <T extends E,​U extends OwnedSubscriber<O,​T>> @NonNull U subscribe​(@NonNull O owner,
                                                                                      @NonNull java.lang.Class<T> eventClass,
                                                                                      @NonNull java.util.function.Consumer<T> consumer)
        Subscribes to the given event see Subscriber.

        The difference between this method and is that this method takes in an extension parameter which allows for the event to be unsubscribed upon extension disable and reloads.

        Type Parameters:
        T - the event class
        Parameters:
        owner - the extension to subscribe the event to
        eventClass - the class of the event
        consumer - the consumer for handling the event
        Returns:
        the event subscription
      • subscribe

        <T extends E,​U extends OwnedSubscriber<O,​T>> @NonNull U subscribe​(@NonNull O owner,
                                                                                      @NonNull java.lang.Class<T> eventClass,
                                                                                      @NonNull java.util.function.Consumer<T> consumer,
                                                                                      @NonNull PostOrder postOrder)
        Subscribes to the given event see Subscriber.

        The difference between this method and is that this method takes in an extension parameter which allows for the event to be unsubscribed upon extension disable and reloads.

        Type Parameters:
        T - the event class
        Parameters:
        owner - the extension to subscribe the event to
        eventClass - the class of the event
        consumer - the consumer for handling the event
        postOrder - the order of the subscriber
        Returns:
        the event subscription
      • register

        void register​(@NonNull O owner,
                      @NonNull java.lang.Object listener)
        Registers events for the given listener.
        Parameters:
        owner - the extension registering the event
        listener - the listener
      • unregisterAll

        void unregisterAll​(@NonNull O owner)
        Unregisters all events from a given owner.
        Parameters:
        owner - the extension
      • subscribers

        <T extends E> @NonNull java.util.Set<? extends OwnedSubscriber<O,​T>> subscribers​(@NonNull java.lang.Class<T> eventClass)
        Description copied from interface: BaseBus
        Gets the subscriptions for the given event class.
        Specified by:
        subscribers in interface BaseBus<O,​E>
        Type Parameters:
        T - the value
        Parameters:
        eventClass - the event class
        Returns:
        the subscriptions for the event class