Tom, that would in theory necessitate multiple listener lines for the same
function in the same controller if it was needed for different events.

Your way (minimum case of one function fired for given event):
2 message broadcasts (event names)
2 message listeners (event name map to function name)
1 controller function

"My" way:
2 message broadcasts (same message, broadcast once each in two different
events)
1 message listener (map message to function name)
1 controller function

Hopefully this illustrates that you're adding extra work (which may be part
of why you're frustrated with the repetitiveness of it?) via extra lines of
XML.

Really, at its core, the issue is that a controller should say, "I can do
thingA" (some business logic) and what triggers it is when you say
"doThingA". What you're doing is writing controllers that can do "thingA"
and know they should do it for eventA, eventB, eventC, and so-on. The more
code-reuse you have, the more event-to-controller-function maps (message
listeners) you need.

Think about a really, really granular piece of buisness logic. The current
screen requires that your session has not exired (you are still logged in).
Broadcast "isUserLoggedIn" and your user controller will listen for
"isUserLoggedIn" and populate a variable in the event context with its
response. Then you can re-use that functionality in as many events as you
need by simply adding its broadcast -- no need for new message listeners,
etc.

Clear as mud, right?

Adam


On Mon, Feb 9, 2009 at 4:12 PM, Tom Chiverton <[email protected]>wrote:

>
> 2009/2/9 Adam Tuttle <[email protected]>:
> > I haven't used Model-Glue for Flex yet, but I suspect that it's for the
> same
> > reason you have to define your broadcasts in MG:CF; because you can (and
> > probably should) have various (multiple!) broadcasts for a given request
> > that have nothing to do with the event name.
>
> Hmm.
> Where I need multiple things to happen in response to the same event,
> I have many control:messageListeners (in different controllers) with
> the same 'message', rather than many 'internal' events.
> Am I 'doing it wrong ?
>
> Could there not be a 'default' 1:1 mapping ?
>
> --
> Tom
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "model-glue" 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/model-glue?hl=en

For more about Model-Glue, check http://www.model-glue.com .
-~----------~----~----~----~------~----~------~--~---

Reply via email to