GWT MVP with Activities and Places - “global”参考? [英] GWT MVP with Activities and Places - "global" references?

查看:85
本文介绍了GWT MVP with Activities and Places - “global”参考?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 GWT与活动的MVP开发有些混淆和地点示例。
这是我第一次采用这种设计模式。我设法在我的项目中实现它,并且让我惊讶的是它确实有效。历史作品,事件发生火灾等等。



由于我完全遵循这个例子,我的演示者是一次性活动,每次用户导航时创建,视图保存在ClientFactory中。所有东西都是分开的,干净的。



现在我不能将自己的头围绕在下面:在我的应用程序中,用户可以随时选择全局选项:事件通知当前活动(这是期望的)。现在我感觉有点傻,但我怎样才能将全局选项对象传递给事件触发后创建的活动?

在示例中, Activities的构造函数接收一个只能容纳简单字符串(全局选项对象不可stringyfiable)和clientFactory的Place参数。
现在我在ClientFactory中放置全局选项,但必须是(或感觉)错误。我应该把它放在创建Activity对象的AppActivityMapper中吗?我在这里错过了什么大的东西?

://stackoverflow.com/questions/5510571/gwt-mvp-with-places-activities-wheres-the-model> GWT MVP with Places& Activities - 模型在哪里?) - Activities& Places演示不包括MVP的模型组件。



虽然感觉不对,但我建议将此模型数据实例存储在您的ClientFactory中,或让您的ClientFactory提供getModel () 方法。数据模型返回可能包含您的全局选项。



上述文章中介绍的替代策略适用于您的一次性活动,实际上从ClientFactory获取持久Presenter,您的活动在创建时检索数据模型。


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. Everything 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.

这篇关于GWT MVP with Activities and Places - “global”参考?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆