在 PureMVC 中为视图组件创建 API?
在 AS3 的上下文中,特别是像 PureMVC 这样的框架,我想知道是否有人可以为我指明正确的方向,以理解视图组件的 API 的含义。
提前致谢。
In the context of AS3 and specifically a framework such as PureMVC, I was wondering if someone could point me in the right direction for understanding what an API for a View Component means.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,你的中介者持有你的视图组件,对吗?假设视图组件是用户输入数据的表单。
由于视图组件无法发送通知,因此需要某种方式将该信息传递给中介者,然后中介者将发送通知。您有两种传递信息的方法:
如果发送事件,中介器和组件之间的耦合就会减少。如果你通过 API 来完成,那就更简单了。
您还可以混合搭配这两种方法。
希望就是这样!
胡安
Well, you have your mediators holding your view components, right? Let's say the view component is a form where the user enters data.
Since the view component cannot send notifications it needs some way to pass that information to the mediator that will then send the notification. You have 2 ways of passing the information:
If you send events, there would be less coupling between mediator and component. If you do it via an API, it would be simpler-ish.
You can also mix and match both methods.
Hope this is it!
Juan
我认为更干净的方法是在中介者 onRegister 方法中仅添加关联视图的事件处理程序。所以它会让你的视图真正可重用并且与中介完全解耦。您的视图不了解中介者,它可以与任何框架一起使用。
I think so more cleaner way is in your mediators onRegister method only add eventhandler for associated view. So it will make your view really reusable and totally decoupled with mediator. Your view doesn't know about mediator and it can be work with any framework.