使 cairngorm 命令始终同步工作
我看到了异步命令的好处(等待服务器响应...),但在我的 Flex 应用程序中,它给我带来了更多的问题。这就是我想要的:
每个命令仅在前一个命令返回后执行(返回结果或错误函数)
并且我想尽可能轻松地执行此操作..顺便说一下,GUI 必须变得无响应(可能是等待消息)正在执行一个长命令(我可以在执行函数中显示等待消息,并在错误或结果函数中将其删除..)
有什么想法吗?
I see the benefit of asynchronous commands (waiting for server responses...) but in my flex app it creates me more problem than anything. Here's what I want:
EVERY command executes only after the previous one returned (to result or fault function)
And I'd like to do this as easily as possible.. by the way the GUI must become irresponsive (maybe a wait message) while a long command is being executed (I could show the wait message in the execute function and remove it in the fault or result function..)
any Idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过扩展 CairngormEvent 类并添加两个属性来实现这一点:
并创建一个新类作为所有命令的基础,它实现 ICommand:
然后在每个命令类中,当必要的逻辑完成时,或者出现错误/失败时,我在 CairngormCommand 基类中调用适当的函数。这是一个示例:
我现在在我的 Cairngorm 应用程序中专门使用它。最好的部分是,如果您不需要成功和/或失败的回调,您可以将这些属性保留在事件实例化之外,然后简单地分派事件。
在加载显示之前加载显示所需的数据的示例:
InitializeApplicationCommand(注意如何可以根据需要多次链接事件和调用者):
I accomplished this by extending the CairngormEvent Class and adding two properties:
And creating a new Class as a base for all Commands, which implements ICommand:
Then in each Command Class, when the necessary logic is complete, or there is an error/failure, I call the appropriate function in the CairngormCommand base Class. Here is an example:
I use this EXCLUSIVELY in my Cairngorm applications now. The best part is, if you don't need to have a callback for success and/or failure, you can just leave those properties out of the event instantiation and simply dispatch the event.
Example of loading data needed for display before the display is loaded:
InitializeApplicationCommand (notice how you can chain the events and callers as many times as you'd like):