Mate Framework - 在进行远程调用之前检查数据

发布于 2024-07-20 07:52:32 字数 361 浏览 6 评论 0原文

直到最近我一直在使用 cairngorm 作为 Flex 的框架。 然而,在这个最新的项目中我已经切换到了 Mate。 这仍然让我有点困惑,因为我已经习惯了将数据留在模型中。 我有几个依赖相同数据集(集合)的组件。 在组件中,创建完成处理程序发送一个“GiveMeMyDataEvent”,该事件由事件映射之一捕获。 现在,在我的命令类中的 cairngorm 中,我可以快速浏览一下模型,以决定是否需要从服务器获取数据,然后从模型返回数据或调用 db。 我该如何在 Mate 中做到这一点? 或者是否有更好的方法来解决这个问题,我正在尝试利用已经从服务器收到的数据,但同时我不确定是否已加载数据。 如果已实例化使用相同数据的组件,则答案为“是”,否则为“否”。 非常感谢任何帮助/提示。

Until recently I have been using cairngorm as a framework for flex. However, in this latest project I have switched to Mate. It's` still confusing me a little as I kind of got used to leaving data in the model. I have a couple of components which rely on the same dataset(collection).
In the component the creation complete handler sends a 'GiveMeMyDataEvent' which is caught by one of the eventmaps. Now in cairngorm in my command class I would have had a quick peek in the model to decide whether I need to get the data from the server or not and then either returned the data from the model or called the db.
How would I do this in Mate? Or is there a better way to go about this, I'm trying to utilize the data that has already been recieved from the server, but at the same time I'm not sure I have loaded the data or not. If a component which uses that same data has been instantiated then the answer is yes otherwise no.
Any help/hints greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

星星的轨迹 2024-07-27 07:52:32

Mate 中的大多数事情都是间接的。 您有管理数据的管理器,并在管理器和视图之间设置注入器(它们是绑定)。 注入者确保你的观点与你的经理同步。 这样视图始终拥有最新数据。 视图不会作为分派事件的直接结果而更新,而是作为间接结果。

当您想要加载新数据时,您可以调度一个由事件映射捕获的事件,事件映射又调用一些服务,该服务加载数据并将其返回到事件映射,然后事件映射将其粘贴到适当的管理器中。

当管理器更新时,注入器确保视图更新。

通过使用注入器,您可以保证视图中始终拥有最新数据,因此,如果视图有数据,则加载数据 - 除非您需要定期更新,在这种情况下,由您来确定数据是否过时并分派触发服务调用的事件,触发更新,触发注入器再次将新数据推送到视图中,然后循环。

因此,简而言之,您问题的答案是您需要确保正确使用注射器。 如果这对您来说太高级了,我知道您可以在 Mate 论坛 中获得更多帮助。

Most things in Mate are indirect. You have managers that manage your data, and you set up injectors (which are bindings) between the managers and your views. The injectors make sure your views are synchronized with your managers. That way the views always have the latest data. Views don't get updated as a direct consequence of dispatching an event, but as an indirect consequence.

When you want to load new data you dispatch an event which is caught by an event map, which in turn calls some service, which loads data and returns it to the event map, and the event map sticks it into the appropriate manager.

When the manager gets updated the injectors make sure that the views are updated.

By using injectors you are guaranteed to always have the latest data in your views, so if the views have data the data is loaded -- unless you need to update periodically, in which case it's up to you to determine if data is stale and dispatch an event that triggers a service call, which triggers an update, which triggers the injectors to push the new data into the views again, and round it goes.

So, in short the answer to your question is that you need to make sure you use injectors properly. If this is a too high-level answer for you I know you can get more help in the Mate forums.

梦忆晨望 2024-07-27 07:52:32

我目前正在开发的应用程序也遇到了类似的情况,并且发现当您开始考虑举办两个事件时,它很容易在 Mate 中实现。

第一个事件类似于 DataEvent.REFRESH_MY_DATA。 该事件由某个 DataManager 处理,DataManager 可以决定忽略它(因为数据已经存在于客户端中并且被认为是最新的),或者管理器可以调度类似 DataEvent.FETCH_MY_DATA 的事件。

FETCH_MY_DATA 事件会触发事件映射中的服务调用,从而更新管理器中的值。 此更新已将属性注入到视图中,快乐的日子:)

I ran into a similiar situation with the app I am working on at the moment, and found that it is easily implemented in Mate when you start thinking about having two events.

The first event being something like DataEvent.REFRESH_MY_DATA. This event is handled by some DataManager, which can decide to either ignore it (since data is already present in the client and considered up to date), or the manager can dispatch an event like DataEvent.FETCH_MY_DATA.

The FETCH_MY_DATA event triggers a service call in the event map, which updates a value in the manager. This update is property-injected into the view, happy days :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文