开发者

One Presenter needing Access to another Presenter's State in GWT MVP

开发者 https://www.devze.com 2023-03-10 08:47 出处:网络
I am making an application where I have three main Presenters. In one say \"ListPresenter\", I hav开发者_开发百科e a Tree with a list of cities.

I am making an application where I have three main Presenters.

In one say "ListPresenter", I hav开发者_开发百科e 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号