Yeah, that would be a possible "solution". But in that way you are missing
the point. You are breaking the hold view encapsulation and the framework
flow.
I´m using another "solution" in a current project:
The model has one or more Signal events (as3Signals) that is fired from a
command. The model itself is a Singleton, so I can do something like this
from the command:
private function OnResult(event:ResultEvent):void
{
var items:ArrayCollection = event.result as ArrayCollection;
MyModel.getInstance().items = items;
MyModel.getInstance().itemsUpdated.dispatch(items); // itemsUpdated is
a simple Signal
}
on the view:
MyModel.getInstance().itemsUpdated.add(ItemsUpdatedHandler);
private function ItemsUpdatedHandler(items:ArrayCollection):void
{
// do something
}
The view is subscribed to that Signal. This way the view can notice when a
command is done and I don´t break the MVC flow because the view only knows
about the model.
What do you think?
2011/2/8 Raj <[email protected]>
>
> hi Diego,
>
> What you probably need is a callback method.
> If view could have a handle to operation's AsynToken, it can attach its own
> responder to it.
>
> This mechanism along with cairngorm's boilerplate code will certainly make
> a project's code complex and difficult to debug.
>
> I would rather share the reference to the service endpoint to the view and
> let view attach a responder to it.
> Am assuming that the view is a large piece of code providing significant
> functionality and not just a tiny view like a Alert with more buttons.
> Then this approach is still scalable as the complexity of that view remains
> in one file.
>
> Every application is different and this approach may not work universally.
>
> regards,
> Raj
>
> 2011/2/3 Diego Ponce de León <[email protected]>
>
>> It is not just "plenty of boiler plate code" thing.
>>
>> For me the Cairngorm´s handicap is that all views are based on data
>> binding. Don´t get me wrong. Flex data binding is a wonderful world, but not
>> for every case.
>>
>> This is a usual scenario:
>>
>>
>> 1. View dispatch an event
>> 2. FrontController catch it and execute a command
>> 3. The command make a service call and wait to response
>> 4. The command gets the service response and modifies the model
>> (bindable)
>> 5. The view updates JUST because a property is binded to the model
>>
>>
>> The last point is very useful sometimes, for example, if you have a list
>> or datagrid listening to some bindable variable at the model.
>> But what happens if you just need to call a method in the view?
>> What happens if you just need to change any value property in the view, not
>> depending on the model?
>>
>> Ok, and you could say: "put that property in the model"...
>> Sadly, that is wrong in many scenarios (too many for me)
>>
>> So, it could happen that a change on the view is not dependent on the
>> model or a variable, and you just need to tell the view to update or change
>> itself in some way.
>> A good example of what I´m talking about are Robotlegs view mediators.
>>
>>
>>
>> 2011/1/25 Prasanna <[email protected]>
>>
>> hello Diego,
>>> Can you justify why Cairngorm is worst?
>>>
>>> On Jan 22, 11:40 pm, Diego Ponce de León <[email protected]> wrote:
>>> > Whatever you do, don't use cairngorm. It's the worst framework I've
>>> ever
>>> > used
>>> > El 22/01/2011 13:27, "naveen SR" <[email protected]> escribió:
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > > If you have communication to server side I would recommend MATE
>>> framework
>>> > > ....http://mate.asfusion.com/.
>>> >
>>> > > I like this framework over the others for several reasons :).
>>> >
>>> > > Thanks,
>>> > > Naveen
>>> >
>>> > > On Sat, Jan 22, 2011 at 4:10 AM, Daniel Gerep <
>>> [email protected]
>>> > >wrote:
>>> >
>>> > >> Hi guys.
>>> >
>>> > >> Which is the best framework to work with Flex? I'll start a new
>>> project
>>> > and
>>> > >> want to use a framework and I don't have to much experience with
>>> Flex.
>>> >
>>> > >> Thanks in advance.
>>> >
>>> > >> --
>>> > >> *Att*
>>> > >> *Daniel Gerep*
>>> > >> *www.redenoos.com.br*
>>> >
>>> > >> --
>>> > >> You received this message because you are subscribed to the Google
>>> Groups
>>> > >> "Flex India Community" group.
>>> > >> To post to this group, send email to [email protected].
>>> > >> To unsubscribe from this group, send email to
>>> > >> [email protected]
>>> <flex_india%2Bunsubscribe@googlegrou ps.com>
>>> >
>>> > <flex_india%[email protected]
>>> <flex_india%252Bunsubscribe@googl egroups.com>
>>> >
>>> > >> .
>>> > >> For more options, visit this group at
>>> > >>http://groups.google.com/group/flex_india?hl=en.
>>> >
>>> > > --
>>> > > You received this message because you are subscribed to the Google
>>> Groups
>>> >
>>> > "Flex India Community" group.> To post to this group, send email to
>>> [email protected].
>>> > > To unsubscribe from this group, send email to
>>> >
>>> > [email protected]
>>> <flex_india%2Bunsubscribe@googlegrou ps.com>
>>> > .> For more options, visit this group at
>>> >
>>> > http://groups.google.com/group/flex_india?hl=en.
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Flex India Community" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group at
>>> http://groups.google.com/group/flex_india?hl=en.
>>>
>>>
>>
>>
>> --
>> Diego Ponce de León
>>
>> http://www.xleon.net
>> http://twitter.com/diegoxleon
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Flex India Community" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/flex_india?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Flex India Community" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/flex_india?hl=en.
>
--
Diego Ponce de León
http://www.xleon.net
http://twitter.com/diegoxleon
--
You received this message because you are subscribed to the Google Groups "Flex
India Community" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/flex_india?hl=en.