一位演示者需要访问 GWT MVP 中另一位演示者的状态
我正在制作一个应用程序,其中有三个主要演示者。
在“ListPresenter”中,我有一棵包含城市列表的树。 在“WritePresenter”中,我输入一些文本并点击更新。该更新针对其中一个城市。 在“ShowPresenter”中,当且仅当当前在列表中单击的该城市有可用更新时,我才会显示更新。
现在我正在做的方式是...... WritePresenter 在 EventBus 上触发一个事件,其中包含触发该事件的项目的详细信息。 ShowPresenter监听这些事件并根据ListPresenter状态需要更新自身。
现在 ShowPresenter 应该如何访问 ListPresenter 状态。我可以从实例化 ListPresenter 的类中获取它的引用。但这似乎不是一个好的设计理念。耦合似乎也在增加。
最好的办法是什么?
I am making an application where I have three main Presenters.
In one say "ListPresenter", I have a Tree with a list of cities.
In one say "WritePresenter", I type in some text and hit update. The update is for one of the cities.
In one say "ShowPresenter", I show the update if and only if an update is availaible for that city which is currently clicked in our list.
Now the way I am doing it is...
WritePresenter fires an event on the EventBus with details of for which item the event is being fired. ShowPresenter listens to these events and based on the ListPresenter state needs to update itself.
Now how should ShowPresenter get access to ListPresenter state. I could just get a refrence of it from the Class which instantiate ListPresenter. But that dosent seem to be a good design idea. Also seems to be increasing coupling.
What can be the best possible way around?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
让 ListPresenter 触发 ShowPresenter 将订阅的另一个事件怎么样?当且仅当 ListPresenter 处于 ShowPresenter 应更新的状态时,才会触发该事件。
How about making ListPresenter fire another event that ShowPresenter would be subscribed to. That event would be fired if, and only if, ListPresenter is in such a state that ShowPresenter should be updated.