Last active
February 6, 2016 08:19
-
-
Save eungju/4f1cea8ba4f91a9cdc4b to your computer and use it in GitHub Desktop.
RxBus
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
bus.publish(new TokenExpiredEvent()); | |
bus.asObservable() | |
.ofType(TokenExpiredEvent.class) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribe(this::onTokenExpiredEvent); |
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
import rx.Observable; | |
import rx.subjects.PublishSubject; | |
import rx.subjects.SerializedSubject; | |
import rx.subjects.Subject; | |
public class RxBus { | |
private final Subject<Object, Object> bus = new SerializedSubject<>(PublishSubject.create()); | |
public void publish(Object event) { | |
bus.onNext(event); | |
} | |
public Observable<Object> asObservable() { | |
return bus; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment