FLEX 命令的困难同步问题(在 cairngorm 中)

发布于 2024-08-17 02:47:50 字数 388 浏览 7 评论 0原文

我的问题,简化了: 我有一个带有 dataProvider“文档”的 dataGrid 数据网格的一列有一个 labelFunction,它获取文档的 project_id 字段,并从可绑定变量“projects”返回项目名称

现在,我调度事件以从服务器下载文档和项目,但是如果文档在项目之前下载,然后标签函数给出错误(没有“projects”变量)

因此,我必须序列化正在执行的命令: getDocuments 命令必须仅在 getProjects 命令之后执行。

但在现实世界中,我有几十个正在下载的资源,并且这些命令并不总是组合在一起(因此我无法从第一个命令的 onSuccess() 方法执行第二个命令,因为它们并不总是必须一起执行..)..

我需要一个简单的解决方案..我需要一个想法..

My problem, simplified:
I have a dataGrid with a dataProvider "documents"
A column of the datagrid has a labelFunction that gets the project_id field of the document, and returns the project name, from a bindable variable "projects"

Now, I dispatch the events to download from the server the documents and the projects, but If the documents get downloaded before the projects, then the label function gives an error (no "projects" variable)

Therefore, I must serialize the commands being executed: the getDocuments command must execute only after the getProjects command.

In the real world, though, I have dozens of resources being downloaded, and those command are not always grouped together (so I can't for example execute the second command from the onSuccess() method of the first, because not always they must be executed together..)..

I need a simple solution.. I need an idea..

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

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

发布评论

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

评论(1

勿挽旧人 2024-08-24 02:47:50

如果我理解正确的话,您需要序列化服务器的回复。我已经使用 AsyncToken 做到了这一点。

方法:在调用远程函数之前,为其添加一个“令牌”。例如,一个 id。服务器对该特定调用的回复将包含该令牌。这样您就可以将多个调用分开并创建远程调用链。

实际上这很酷:

    service:RemoteObject;
    // ..      
    var call:AsyncToken = service.theMethod.send();
    call.myToken = "serialization id";

    private function onResult(event:ResultEvent):void 
    {
       // Fetch the serialization id and do something with it
       var serId:String = event.token.myToken;
    }

If I understand you correctly, you need to serialize the replies from the server. I have done that by using AsyncToken.

The approach: Before you call the remote function, add a "token" to it. For instance, an id. The reply from the server for that particular call will then include that token. That way you can keep several calls separate and create chains of remote calls.

It's quite cool actually:

    service:RemoteObject;
    // ..      
    var call:AsyncToken = service.theMethod.send();
    call.myToken = "serialization id";

    private function onResult(event:ResultEvent):void 
    {
       // Fetch the serialization id and do something with it
       var serId:String = event.token.myToken;
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文