Created
May 8, 2017 07:20
-
-
Save chowaikong/7007c98c84ecde5014c0a6db392648ce to your computer and use it in GitHub Desktop.
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 RxBus { | |
private final FlowableProcessor<Object> bus = PublishProcessor.create().toSerialized(); | |
private RxBus() { | |
} | |
private static class InstanceHolder { | |
private static final RxBus sInstance = new RxBus(); | |
} | |
public static RxBus getInstance() { | |
return InstanceHolder.sInstance; | |
} | |
public void send(Object o) { | |
bus.onNext(o); | |
} | |
public <T> Flowable<T> toFlowable(Class<T> eventType) { | |
return bus.ofType(eventType); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment