views:

53

answers:

2

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.

+1  A: 

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

Zárate
Very much appreciated Zárate!
rey
A: 

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.

Silent Warrior