ما الذي تم تمريره EventBus في التظليل الذهني. المقصود في GWT
-
15-11-2019 - |
سؤال
قبل استخدام إطار الأنشطة، عادة ما يكون لديك مثيل عالمي / Singleton واحد من GWT EventBus.الآن لاحظت أن فئة النشاط تمر بمثال في أنشطتي.هل هذا EventBus يهدف إلى القيام بالرسالة العامة من جانب العميل عبر التطبيق أو شيء آخر؟
المحلول
It is a reference to the same EventBus
that you instantiated the ActivityManager
with, and is intended to be used as a global event bus for the whole application. Use it for things that transcend an Activity
.
Before it is passed into your activity, it gets wrapped so that any handlers you add to it only get called while the activity is still active (which simplifies clean up).
From the start()
JavaDoc:
Any handlers attached to the provided event bus will be de-registered when the activity is stopped, so activities will rarely need to hold on to the HandlerRegistration instances returned by EventBus.addHandler(com.google.web.bindery.event.shared.Event.Type, H).