Note that there are some explanatory texts on larger screens.

plurals
  1. POMVC principile in flex/as3
    text
    copied!<p>I am currently working on several flex projects, that have gone in a relative short amount of time from prototype to almost quite large applications. <br /> Time has come for some refactoring to be done, so obviously the mvc principle came into mind. <br /> For reasons out my control a framework(i.e. robotlegs etc.) is not an option. <br /> Here comes the question...what general guidelines should I take into consideration when designing the architecture?</p> <p>Also...say for example that I have the following: View, Ctrl, Model.<br /></p> <p>From View:<br /></p> <pre><code>var ctrlInstance:Ctrl= new Ctrl(); ctrl.performControllerMethod(); </code></pre> <p>In Controller</p> <pre><code>public function performControllerMethod():void{ //dome some sort of processing and store the result in the model. Model.instance.result = method_scope_result; } </code></pre> <p>and based on the stored values update the view.<br /> As far as storing values in the model, that will be later used dynamically in the application, via time filtering or other operation, everything is clear, but in cases where data just needs to go in(say a tree that gets populated once at loading time), is this really necessary to use the view->controller->model->view update scheme, or can I just make the controller implement IEventDispatcher and dispatch some custom events, that hold necessary data, after the controller operation finished.</p> <p>Ex: <br /> View:<br /></p> <pre><code>var ctrlInstance:Ctrl= new Ctrl(); ctrl.addEventListener(CustomEv.HAPPY_END, onHappyEnd); ctrl.addEventListener(CustomEv.SAD_END, onSadEnd); ctrl.performControllerMethod(); </code></pre> <p><br/> Controller</p> <pre><code>public function performControllerMethod():void{ (processOk) ? dispatchEvent(new CustomEv(CustomEv.HAPPY_END, theData)) : dispatchEvent(new CustomEv(CustomEv.SAD_END)); } </code></pre> <p><br /> When one of the event handlers kicks into action do a cleanup of the event listeners(via event.currentTarget).</p> <p><br /> As I realize that this might not be a question, but rather a discussion, I would love to get your opinions.<br /></p> <p>Thanks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload