Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

跨类不行吗? #3

Open
choubaguai opened this issue Oct 31, 2016 · 0 comments
Open

跨类不行吗? #3

choubaguai opened this issue Oct 31, 2016 · 0 comments

Comments

@choubaguai
Copy link

choubaguai commented Oct 31, 2016

从loginactivity将消息发给mainactivity的一个fragment中,该如何操作呢。

不好意思,由于rxjava已经升级为2.x,在实际项目中也并不会这样使用,所以我已经放弃了该库的维护,所以也没有再关注过这个库。

关于2.x以后的rxbus 参考
public final class RxBus {
private static RxBus instance;

private Subject<Object> bus;

public static RxBus getInstance() {
    if (instance == null) {
        instance = new RxBus();
    }
    return instance;
}

private RxBus() {
    if (bus == null) {
        synchronized (RxBus.class) {
            if (bus == null) {
                bus = PublishSubject.create().toSerialized();
            }
        }
    }
}

public void post(Object event) {
    bus.toSerialized().onNext(event);
}

public <T> Observable<T> getEvent(Class<T> eventType) {
    return  bus.toSerialized().ofType(eventType);
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant