具有活动和地点的 GWT MVP - “全球"参考? [英] GWT MVP with Activities and Places - "global" references?

查看:23
本文介绍了具有活动和地点的 GWT MVP - “全球"参考?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 GWT MVP Development with Activities 有点困惑和地点示例.这是我第一次接触这样的设计模式.我设法在我的项目中实现了它,令我惊讶的是它确实有效.历史作品、事件火爆等

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.

由于我完全按照示例进行操作,因此我的演示者是每次用户导航时创建的一次性活动,并且视图保存在 ClientFactory 中.一切都是分开的,干净的.

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.

现在我无法解决以下问题:在我的应用程序中,用户可以随时选择一个全局选项:这会触发一个事件,通知 当前 Activity(这是需要的).现在我觉得有点傻,但是如何将全局选项对象传递给事件触发后创建的活动?

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?

在示例中,Activity 的构造函数接收一个 Place 参数,该参数只能保存简单的字符串(全局选项对象不是 stringyfiable)和 clientFactory.现在我将全局选项放在 ClientFactory 中,但这肯定是( 或感觉)错误的.我应该将它放在创建 Activity 对象的 AppActivityMapper 中吗?我在这里错过了什么大事吗?

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?

推荐答案

您在 Stack Overflow (GWT MVP with Places & 活动 - 模型在哪里?) - 活动 &Places 演示未涵盖 MVP 的模型组件.

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.

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

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.

上述文章中提出的替代策略是让您的一次性"活动实际上从 ClientFactory 获取持久的 Presenter,或者让您的活动在创建时检索数据模型.

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 - “全球"参考?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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