简体   繁体   English

Guava EventBus:在GUI应用程序中放置它的位置?

[英]Guava EventBus : where to put it in GUI application?

Is there a best place to put a guava EventBus in a GUI application ? 是否有将guava EventBus放入GUI应用程序的最佳位置? Is there in the Model, the View, or the Controler ? 模型,视图或控制器中是否有? Or three EventBus in the three levels ? 或三个级别的三个EventBus? Or only two of them ? 或者只有两个?

Thanks. 谢谢。

The event bus design pattern is often used in Swing applications (as mentioned in this other SO question ). 事件总线设计模式通常用于Swing应用程序(如其他SO问题中所述 )。

Guava's EventBus is just another implementation of the design pattern, with some cool tricks to simplify event handling (such as using annotations). Guava的EventBus只是设计模式的另一个实现,有一些很简单的技巧来简化事件处理(例如使用注释)。 But the goal of using the design pattern stays the same. 但使用设计模式的目标保持不变。

If I were you, I'd look into how the event bus pattern is usually used in rich client applications (on SO / Google), while using the Guava EventBus to simplify your code. 如果我是你,我会研究如何在富客户端应用程序(在SO / Google上)中使用事件总线模式,同时使用Guava EventBus来简化代码。

The EventBus should IMO be a singleton (ideally injected through Google Guice or some other DI framework). EventBus应该是IMO的单身人士(理想情况下通过Google Guice或其他一些DI框架注入)。

I'm not a Swing dev, but I've done GWT development. 我不是Swing dev,但我已经完成了GWT开发。 A while ago, there was a big push toward the MVP / EventBus architecture for GWT applications. 不久之前,GWT应用程序的MVP / EventBus架构有了很大的推动力。 It might be work looking into it, to see if you could apply the same ideas to your Swing app. 它可能是调查它,看看你是否可以将相同的想法应用到你的Swing应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM