PultusRxBus
PultusRxBus is a EventBus library based on RxJava2 for Android / Java / Kotlin.
Usages
In your build file add
Gradle
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
And
dependencies {
compile 'ninja.sakib:PultusRxBus:beta-0.2'
}
Maven
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
And
<dependency>
<groupId>ninja.sakib</groupId>
<artifactId>PultusRxBus</artifactId>
<version>beta-0.2</version>
</dependency>
In case you need jar download is available here.
More option can be found here.
Examples
Lets say we want to catch event for class SampleEvent
public class SampleEvent {
}
Then implement Consumer interface to receive event,
public class SampleEventReceiver implements Consumer<SampleEvent> {
@Override
public void accept(SampleEvent event) throws Exception {
// You will get event callback here
}
}
Now subscribe,
String consumerId = "123";
PultusRxBus.getInstance().subscribe(SampleEvent.class, consumerId, new SampleEventReceiver());
Finally publish,
PultusRxBus.getInstance().publish(new SampleEvent());
To unsubscribe,
PultusRxBus.getInstance().unsubscribe(consumerId);
License
Copyright © Sakib Sami
Distributed under MIT license