开发者

GWT MVP with Activities and Places - "global" references?

I'm slightly confused with the GWT MVP Development with Activities and Places example. It's the first time I approach such a design pattern. I managed to implement it in my project, and to my surprise it actually works. History works, events fire fine, etc.

Since I am following the example exactly, my presenters are disposable Activities that are created each time the user navigates, and the views are kept in a ClientFactory. Every开发者_JS百科thing is separated and clean.

Now I can't wrap my head around the following: In my application the user can select a global option at any time: This fires an event which notifies the current Activity (which is desired). Now I feel a bit silly, but how can I pass the global option object to Activities created after the event fired?

In the example the constructors of Activities receive a Place parameter which can only hold simple Strings (the global options object is not stringyfiable) and the clientFactory. Right now I'm putting the global options in the ClientFactory but that must be (or feels) wrong. Should I maybe place it in the AppActivityMapper, which creates the Activity objects? Am I missing something big here?


you've encountered the problem described elsewhere in Stack Overflow (GWT MVP with Places & Activities - Where's the Model?) - the Activities & Places demo doesn't cover the Model component of MVP.

Whilst it feels wrong, I recommend store this model data instance in your ClientFactory, or have your ClientFactory provide a getModel() method. The data model return could include your global option.

Alternate strategies presented in the above article are for your 'disposable' activities actually obtain a persistent Presenter from the ClientFactory, or for your Activity to retrieve the data model on creation.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜