在使用事件框架之前,我通常会有一个 GWT EventBus 的 Global/Singleton 实例。现在我注意到事件类将一个实例传递到我的事件中。这个事件总线是用来做跨应用程序客户端通用消息传递还是其他什么?
最佳答案
它是对同一个 EventBus
的引用你实例化了 ActivityManager
与,旨在用作整个应用程序的全局事件总线。将它用于超越 Activity
的事物.
在它被传递到您的事件之前,它会被包装起来,这样您添加到它的任何处理程序只会在事件仍然处于事件状态时被调用(这简化了清理)。
来自 start()
Java文档:
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).
关于gwt - 传递到 GWT 中的 AbstractActivity.start 的 EventBus 打算用于什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9524004/