Guava EventBus:在GUI应用程序中放置它的位置?(Guava EventBus : where to put it in GUI application?)

编程入门 行业动态 更新时间:2024-10-26 00:22:52
Guava EventBus:在GUI应用程序中放置它的位置?(Guava EventBus : where to put it in GUI application?)

是否有将guava EventBus放入GUI应用程序的最佳位置? 模型,视图或控制器中是否有? 或三个级别的三个EventBus? 或者只有两个?

谢谢。

Is there a best place to put a guava EventBus in a GUI application ? Is there in the Model, the View, or the Controler ? Or three EventBus in the three levels ? Or only two of them ?

Thanks.

最满意答案

事件总线设计模式通常用于Swing应用程序(如其他SO问题中所述 )。

Guava的EventBus只是设计模式的另一个实现,有一些很简单的技巧来简化事件处理(比如使用注释)。 但使用设计模式的目标保持不变。

如果我是你,我会研究如何在富客户端应用程序(在SO / Google上)中使用事件总线模式,同时使用Guava EventBus来简化代码。

EventBus应该是IMO的单身人士(最好通过Google Guice或其他一些DI框架注入)。

我不是Swing dev,但我已经完成了GWT开发。 不久之前,GWT应用程序的MVP / EventBus架构有了很大的推动力。 它可能是调查它,看看你是否可以将相同的想法应用到你的Swing应用程序。

The event bus design pattern is often used in Swing applications (as mentioned in this other SO question).

Guava's EventBus is just another implementation of the design pattern, with some cool tricks to simplify event handling (such as using annotations). 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.

The EventBus should IMO be a singleton (ideally injected through Google Guice or some other DI framework).

I'm not a Swing dev, but I've done GWT development. A while ago, there was a big push toward the MVP / EventBus architecture for GWT applications. It might be work looking into it, to see if you could apply the same ideas to your Swing app.

更多推荐

本文发布于:2023-07-25 10:46:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1260050.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   位置   EventBus   Guava   GUI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!