Last active
July 14, 2016 17:51
-
-
Save JosiasSena/bad1e5e8b6f1964f3839e2012a70374e to your computer and use it in GitHub Desktop.
RxJavaEventBusExample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EventBus { | |
private final Subject<Boolean, Boolean> eventBus = new SerializedSubject<>(PublishSubject.<Boolean>create()); | |
private EventBus() { | |
} | |
private static class SingleTonHelper { | |
private static final EventBus INSTANCE = new EventBus(); | |
} | |
public static EventBus getInstance() { | |
return SingleTonHelper.INSTANCE; | |
} | |
public void send(boolean isBoolean) { | |
eventBus.onNext(isBoolean); | |
} | |
public void onError(Throwable throwable) { | |
eventBus.onError(throwable); | |
} | |
public void onCompleted() { | |
eventBus.onCompleted(); | |
} | |
public Observable<Boolean> toObservable() { | |
return eventBus; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment