PureMVC explained in a simple manor
Whatever you do, don't look at the diagram on PureMVC's website. It will just confuse the hell out of you.
I'm about to explain PureMVC as I understand it in the simplest manor. If my explanation is incorrect, let me know so I can correct it.
[insert marketing about how great PureMVC is here]. So you have the "model" the "view" and the "controller". Controller's do stuff, the model is stuff, and the view shows the stuff. PureMVC is just a way to orchestrate all that... well... stuff! The bases of how that happens is by sending "notifications." A notification in PureMVC is pretty much like an event. You send these events from two places, the "mode" through something called a "proxy" and the "view" with something called a "mediator." When these notifications get sent out, the "Controller" catches them and executes a "command." So the "controller" is the go-between the two. The "Facade" is just something that kinda sits above it all. Now the "mediator" is allowed to control things relating to how the view is displayed, which view is displayed etc. But any business logic happens in the "command" which is the controller. You can still use regular events too... but only between the view and the mediator. Then you'll want to send a notification.
Here's a quick example. Let's say you want to "add a user" from a view. You would create the user object, add it to the body of a notification, send that notification. The application facade knows which controller these notifications go to (because you tell it). The command calls the proxy (remember that the proxy is how you interact with the model) and tells it to add the user. The proxy sends a notification when this is complete. The command might do an alert that says "user added". Make sense? Or did I totally confuse you?
To be honest, I'm really writing this to help me understand pureMVC better. On my next post, I think I'm going to do ASFusion's MATE.
Hopefully this paragraph will make things a little simpler when you go to look at some PureMVC examples.

0 Comments:
Post a Comment
<< Home