Package app.pivo.android.prosdk.events
Class PivoEventBus
java.lang.Object
app.pivo.android.prosdk.events.PivoEventBus
public final class PivoEventBus extends Object
PivoEventBus allows to listen and send Pivo events
PivoEvent in different components of the application.-
Field Summary
Fields Modifier and Type Field Description static intCONNECTION_COMPLETEDConnection completed subject.static intCONNECTION_FAILUREConnection failed or an app is disconnected from Pivo.static intMAC_ADDRESSMacAddress subjectstatic intNAME_CHANGEDName is changed subject.static intPIVO_NOTIFICATIONPivo notification subjectstatic intREMOTE_CONTROLLERRemote controller subject.static intSCAN_DEVICEScan device subject. -
Method Summary
Modifier and Type Method Description static voidpublish(int subject, Object message)Publish an object to the specified subject for all subscribers of that subject.static voidsubscribe(int subject, Object lifecycle, io.reactivex.functions.Consumer<Object> action)Subscribe to the specified subject and listen for updates on that subject.static voidunregister(Object lifecycle)Unregisters this object from the bus, removing all subscriptions.
-
Field Details
-
CONNECTION_COMPLETED
public static final int CONNECTION_COMPLETEDConnection completed subject.- See Also:
- Constant Field Values
-
CONNECTION_FAILURE
public static final int CONNECTION_FAILUREConnection failed or an app is disconnected from Pivo.- See Also:
- Constant Field Values
-
SCAN_DEVICE
public static final int SCAN_DEVICEScan device subject.- See Also:
- Constant Field Values
-
REMOTE_CONTROLLER
public static final int REMOTE_CONTROLLERRemote controller subject.- See Also:
- Constant Field Values
-
NAME_CHANGED
public static final int NAME_CHANGEDName is changed subject.- See Also:
- Constant Field Values
-
PIVO_NOTIFICATION
public static final int PIVO_NOTIFICATIONPivo notification subject- See Also:
- Constant Field Values
-
MAC_ADDRESS
public static final int MAC_ADDRESSMacAddress subject- See Also:
- Constant Field Values
-
-
Method Details
-
subscribe
public static void subscribe(int subject, @NonNull Object lifecycle, @NonNull io.reactivex.functions.Consumer<Object> action)Subscribe to the specified subject and listen for updates on that subject. Pass in an object to associate your registration with, so that you can unsubscribe later.
Note: Make sure to callunregister(Object)to avoid memory leaks. -
unregister
Unregisters this object from the bus, removing all subscriptions. This should be called when the object is going to go out of memory. -
publish
Publish an object to the specified subject for all subscribers of that subject.
-