public class GfgRxGfgSampleBus {
public GfgRxGfgSampleBus() {
}
private CoursePublications
Java
public class GfgSampleApp extends Application {
private RxSampleBus sampleBus;
// Declaring an object
@Override
public void onCreate() {
super.onCreate();
sampleBus = new RxSampleBus();
}
public RxSampleBus sampleBus() {
return sampleBus;
}
}
Java
((SampleGfGApp) getApplication())
.sampleBus()
.toObservable()
.subscribe(new Consumer() {
@Override
public void accept(Object gfgObject) throws Exception {
if (gfgObject instanceof EventTypeOne) {
Logger.d("GfG Articles are the best One");
} else if (gfgObject instanceof EventTypeTwo) {
Logger.d("GfG Articles are the best Two");
}
}
});
((SampleGfGApp) getApplication())
.sampleBus()
.toObservable()
.subscribe(new Consumer() {
@Override
public void accept(Object gfgObject) throws Exception {
if (gfgObject instanceof EventTypeOne) {
Logger.d("GfG Articles are the best One");
} else if (gfgObject instanceof EventTypeTwo) {
Logger.d("GfG Articles are the best Two");
}
}
});