Closed UltramanTIGA closed 6 years ago
作者你好,我碰到了一个问题,我在adapter里使用Apollo.emit发送事件,在已经bind的Fragment里面无法接收到相应的事件。而如果在Fragment发送,则可以正常在Fragment接收。
Apollo是不是只能在Activity或Fragment中发送事件才能被正常接收呢,还是说发送事件的类也需要进行bind操作?
在任何地方你都可以emit,事件是已经发送出去了的,但是可能接收函数还没有被注册到Apollo事件总线中,所以表现出来的状态是event没有发送出去。
在Adapter中emit事件是可以被接收到的,但前提是你的Fragment已经是起起来的。
如果此时Fragment还没有起起来,此时你用Apollo.emit()它是收不到的。
这种情况下你需要@Sticky注解接收函数。
多谢回复,已经解决
作者你好,我碰到了一个问题,我在adapter里使用Apollo.emit发送事件,在已经bind的Fragment里面无法接收到相应的事件。而如果在Fragment发送,则可以正常在Fragment接收。
Apollo是不是只能在Activity或Fragment中发送事件才能被正常接收呢,还是说发送事件的类也需要进行bind操作?