如何在Flex中调度creationComplete事件后初始化一些变量
我尝试发送一些服务来获取creationComplete 处理程序中的数据。然后我需要在显示一些子组件之前处理服务器原始数据。我应该把这种代码放在哪里?
I tried to send some services to fetch data in the creationComplete handler. Then I need to process the server raw data before displaying some sub-components. Where should I put this kind of code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,我使用 Mate 作为我的应用程序框架。在这种情况下它绝对有帮助。
当我过去需要做这种事情时,我会在我的
creationComplete
处理程序中进行服务调用,并在所有数据处理完毕并将其分发到我的子组件后调度自定义事件。演示模型。将数据绑定到我的所有子组件后,我将它们的可见性设置为 true 或将它们添加到应用程序中,具体取决于需要发生的情况。
First off, I use Mate as my application framework. It definitely helps in situations like this.
When I've needed to do this kind of thing in the past I would make my service call in my
creationComplete
handler and dispatch a custom event once all my data has been processed and distributed to my sub components' presentation models.After the data was bound to all of my sub components I set their visibility to true or add them to the app, depending on what needed to happen.
您已经可以在应用程序的 preinitialize 方法上调用服务,但这并不意味着您将在分派creationComplete 之前获得结果。
如果你想在得到结果后显示子组件,我建议你看看Flex states。或者您可以使用组件的可见属性。有时,得到你需要的东西就足够了。
You can already call services on the preinitialize method of your Application but it doesn't mean you will get your results before the creationComplete is dispatched.
If you want to display subcomponents after you get the results, I suggest you to have a look at Flex states. Or you can play with the visible property of you components. Sometimes it's enough to get what you need.