AndroidKnife / RxBus

Event Bus By RxJava.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How can I use it in Kotlin?

verehu opened this issue · comments

commented

In Kotlin, annotations is not support. When I use @subscribe, it show errors.

commented

I had subscribe it like this,

 @Subscribe(
            thread = EventThread.MAIN_THREAD,
            tags = arrayOf(Tag(BusTag.VideoPlay.PROGRESS_CHANGED))
    )
    fun onVideoProgressChanged(progress: Int) {

    }

I post event in sub thread,

          RxBus.get().post(BusTag.VideoPlay.PROGRESS_CHANGED,
                            (100 * 87L / 100L).toInt())

I debug the code,find the Int in Kotlin is not same as the Integer in java, so

 Set<SubscriberEvent> wrappers = getSubscribersForEventType(new EventType(tag, clazz));

wrappers can't be found.It dispatch a DeadEvent.

i got the same problem here

Yes, the type here is not compatible.

@bluemix @WellerV 发送的事件不能是基本类型就ok了 改成String类型

commented

@Blizzard-liu 自己修改源码解决了,不可能所有int类型的都改成String,这个还是很影响效率的。

如果有兴趣,可以提交一个 pull request 过来。

Hello, when will the version with the Kotlin fix be released?

@kssilvoza Already released for 2.0.1 version.

commented

@hwangjr 2.0.1 没有合入#95的代码
image

@mozhou5555 already release 2.0.2 & 3.0.0