Eventbus是中介者还是观察者模式?

Eventbus是中介者还是观察者模式?

问题描述:

Eventbus是更多的中介者还是观察者?根据Google的说法, 事件总线调解器"获得2.430的点击率, 事件总线观察器"获得了3.850次点击.

Is Eventbus more a Mediator or an Observer? According to Google, "eventbus mediator" gets 2.430 hits and "eventbus observer" gets 3.850 hits.

根据描述,它们都将与我试图做的事情相匹配(调解员甚至更多). 那么事件总线是实现特定的模式还是由我决定是由我决定的?

From the description, they would both match what I was trying to do (the mediator even a little more). So does eventbus implement a specific pattern or is it up to me which I say it is?

通常,给定的代码本质上并不是一个模式或另一个模式的示例.这就是为什么它们被称为模式"(而不是实现技术")的原因.许多软件有点像一种模式,但又类似于另一种模式-很好.最好不要为了模式而坚持使用模式,而应将它们用作讨论体系结构的共享词汇.

Often, a given piece of code isn't intrinsically an example of one pattern or another. This is why they're called "patterns" (rather than, say, "implementation techniques"). A lot of software kinda looks like one pattern, but also resembles another -- this is good. It's best not to adhere to patterns for patterns' sake, but to use them as a shared vocabulary for discussing architecture.

EventBus就是这样一种工具.我是在考虑类似Observer的情况下编写它的,但是如果适当地构建应用程序,它可以起到Mediator的作用.

EventBus is one such tool. I wrote it with Observer-like situations in mind, but if you structure your application appropriately it can play a Mediator-like role.