-
- All Implemented Interfaces:
-
com.onesignal.common.events.ICallbackNotifier
public class CallbackProducer<THandler extends Object> implements ICallbackNotifier<THandler>
A standard implementation that implements ICallbackNotifier and additional functionality to make callbacks less burdensome to the user.
-
-
Field Summary
Fields Modifier and Type Field Description private final BooleanhasCallback
-
Constructor Summary
Constructors Constructor Description CallbackProducer()
-
Method Summary
Modifier and Type Method Description BooleangetHasCallback()Unitset(THandler handler)Set the callback. final Unitfire(Function1<THandler, Unit> callback)Call this to fire the callback which will allow the caller to drive the calling of the callback handler if one exists. final UnitfireOnMain(Function1<THandler, Unit> callback)Call this to fire the callback which will allow the caller to drive the calling of the callback handler if one exists. final UnitsuspendingFire(SuspendFunction1<THandler, Unit> callback)Call this to fire the callback which will allow the caller to drive the calling of the callback handler if one exists. final UnitsuspendingFireOnMain(SuspendFunction1<THandler, Unit> callback)Call this to fire the callback which will allow the caller to drive the calling of the callback handler if one exists. -
-
Method Detail
-
getHasCallback
Boolean getHasCallback()
-
set
Unit set(THandler handler)
Set the callback.
- Parameters:
handler- The handler that will be called when required.
-
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 handler if one exists. It is done this way to avoid this abstract class from knowing the specific signature of the handler.
- Parameters:
callback- The callback will be invoked if one exists, 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 handler if one exists. It is done this way to avoid this abstract class from knowing the specific signature of the handler. 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 if one exists, 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 handler if one exists. It is done this way to avoid this abstract class from knowing the specific signature of the handler.
- Parameters:
callback- The callback will be invoked if one exists, 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 handler if one exists. It is done this way to avoid this abstract class from knowing the specific signature of the handler. The callback will be invoked on the main thread.
- Parameters:
callback- The callback will be invoked if one exists, allowing you to call the handler.
-
-
-
-