Package 

Class EventProducer

  • All Implemented Interfaces:
    com.onesignal.common.events.IEventNotifier

    
    public class EventProducer<THandler extends Object>
     implements IEventNotifier<THandler>
                        

    A standard implementation that implements IEventNotifier and additional functionality to make event firing less burdensome to the user.

    • Constructor Detail

      • EventProducer

        EventProducer()
    • Method Detail

      • subscribe

         Unit subscribe(THandler handler)

        Subscribe to listen for events.

        Parameters:
        handler - The handler that will be called when the event(s) occur.
      • unsubscribe

         Unit unsubscribe(THandler handler)

        Unsubscribe to no longer listen for events.

        Parameters:
        handler - The handler that was previous registered via subscribe.
      • fire

         final Unit fire(Function1<THandler, Unit> callback)

        Call this to fire the callback which will allow the caller to drive the calling of the callback handlers if there are any.

        Parameters:
        callback - The callback will be invoked for each subscribed handler, allowing you to call the handler.
      • fireOnMain

         final Unit fireOnMain(Function1<THandler, Unit> callback)

        Call this to fire the callback which will allow the caller to drive the calling of the callback handlers if there are any. The callback will be invoked asynchronously on the main thread. Control will be returned immediately, most likely prior to the callbacks being invoked.

        Parameters:
        callback - The callback will be invoked for each subscribed handler, allowing you to call the handler.
      • suspendingFire

         final Unit suspendingFire(SuspendFunction1<THandler, Unit> callback)

        Call this to fire the callback which will allow the caller to drive the calling of the callback handlers if there are any.

        Parameters:
        callback - The callback will be invoked for each subscribed handler, allowing you to call the handler.
      • suspendingFireOnMain

         final Unit suspendingFireOnMain(SuspendFunction1<THandler, Unit> callback)

        Call this to fire the callback which will allow the caller to drive the calling of the callback handlers if there are any. The callback will be invoked on the main thread.

        Parameters:
        callback - The callback will be invoked for each subscribed handler, allowing you to call the handler.