greenrobot / EventBus

Event bus for Android and Java that simplifies communication between Activities, Fragments, Threads, Services, etc. Less code, better quality.
http://greenrobot.org/eventbus/
Apache License 2.0
24.67k stars 4.66k forks source link

EventBus.getDefault().register Can it be put into asynchronous initialization? #722

Closed AndroidLMY closed 4 months ago

AndroidLMY commented 9 months ago

EventBus.getDefault().register是否可以放到异步初始化?

Translation: EventBus.getDefault().register Can it be put into asynchronous initialization?

mlzhang920802 commented 9 months ago

既然支持线程调度,理论上是支持的

greenrobot-team commented 9 months ago

EventBus.getDefault() is thread-safe, so that should not be an issue. But be aware that register will throw an exception if the subscriber is already registered. Maybe add a isRegistered check first.