gwt - 传递到 GWT 中的 AbstractActivity.start 的 EventBus 打算用于什么?

标签 gwt gwt-mvp event-bus gwt-activities

在使用事件框架之前,我通常会有一个 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/

相关文章:

java - 如何在我的 gwt 应用程序中导入 java.security.*

java - 如何在不使用 Eclipse 的情况下调试 gwt 应用程序

java - 如何处理来自 Presenter 的 Datagrid 列事件?

java - Greenbot Eventbus 3.0 : What is the difference between onEvent, onEventMainThread、onEventBackgroundThread 和 onEventAsync?

java - vertx访问verticle类之外的事件总线

gwt - MVP GWT - 注入(inject) EventBus 的问题

java - 尝试将我的 GWT 项目拆分为多个模块 - "did you forget to inherit a required module?"

java - 基于MVP(Model View Presenter)我应该如何实现?

GWT 最佳实践 - MVP

java - 如何使用 IPC EventBus 发布事件?