Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 05-16-2009, 08:13 PM   #1
Registered User
Join Date: Feb 2009
Posts: 4
Default MVC event with lots of properties

Hi all,

I have a view component which pulls in about 15 different properties from the model. There is another view component which provides user controls (sliders, text input, etc) for each of the properties in the first view. When the user modifies one of the controls I want to fire an event which sends the updated control data to a listening command, who updates the model, instantly updating the first view.

Having 15 events/commands seems like overkill. I'd like to have one event (PropertyUpdateEvent) which takes as data the property that was changed and a command which listens, sees the property that changed and updates that property in the model.

What I don't know is how to organize the property data inside the event. I have two ideas:

1) I could have one event with 15 properties all set to null and a view which instantiates the event setting only the property that was modified and leaving the rest of the (non-modified) properties as null. (The event should fire as soon as one property is changed. So only one property at a time will ever be changed.) Then the command will just update any non-null property. This approach seems to be sending a lot of data, even though only 1 property at a time will be used.

2) I could have the event accept a key (property name) and value (property value) and pass it to the command. But this approach seems rather loose.

3) I could wrap the property data (name and new value) in some kind of container object. The container would know about all of the possible property names (as string consts) and can be constructed with a valid property name and it's new value. This seems tighter than #2, but then both the view and model would need to know about the container object. Is this fair in MVC?

Is there a better way?
asciiman is offline   Reply With Quote
Old 05-16-2009, 08:25 PM   #2
Registered User
Join Date: Feb 2009
Posts: 4
Default Answered my own question

Funny how after a while of thinking, I need to actually write the post to answer my own question.

The answer is #3. I just remembered the use to Value Objects (VO) which I believe is exactly the kind of container I need to use to pass this info.
asciiman is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Dispatching event from one class and listening in another pratikhunt ActionScript 3.0 5 07-21-2009 01:56 PM
addChild in the REMOVED event handler - tricky!!! amarghosh ActionScript 3.0 2 07-10-2008 10:55 AM
dispatchEvent and set Event properties Flash Gordon ActionScript 3.0 5 06-25-2007 04:02 AM
dispatching a custom event from another event handler method Daedalus ActionScript 3.0 5 01-20-2007 07:35 PM
Dispatching custom event to multiple objects. antoinettemonthon ActionScript 2.0 0 11-08-2006 01:46 PM

All times are GMT. The time now is 02:33 AM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.