Creating an API for a View Component in PureMVC?
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.
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:
- You make your view component expose an API (a set of public methods / variables).
- You make your view component send events when the information changes.
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
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.
精彩评论