关于EventBus消息互窜的问题

EventBus在post的时候会扫描所有带这个post对象的注册过的实例。

所以可能会导致post某个对象很多注册者都收到这个消息,但是有时候我们并不想要所有人都收到,基于这个需要对eventbus进行扩展。

github地址:https://github.com/f059074251/XEventBus

jCenter配置:com.tiger:xeventbus:1.1.0

 使用方式: //MainActivity.this为需要接收到的对象

 1.XEventBus.getDefault().post(new Test(MainActivity.this));

2.

XEventBus.getDefault().post(new Test(new IXEventSubsciber() {
    @Override
    public Object getId() {
        return MainActivity.this;
    }
}));
注册者需要实现IXEventSubsciber接口

你可能感兴趣的:(关于EventBus消息互窜的问题)