Search the web
Sign In
New User? Sign Up
flexcoders · RIA Development with Adobe Flex
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
What do you think of UM Cairngorm Extensions,especially for Modular   Message List  
Reply | Forward Message #109901 of 150922 |
Re: [flexcoders] Re: What do you think of UM Cairngorm Extensions,especially for Modular Apps?

On Sun, Apr 13, 2008 at 10:50 AM, Doug McCune <doug@...> wrote:
> we'll be pushing out more examples, especially of how to use the
> EventGenerator since that's something I think a lot of people have
> needed to do.

Yeah, on has to go over the code a bit to see how it works, but that
EventGenerator is pretty flexible and easy to use once you understand
how the UMEvents, on which it relies, work.

UMEvents are CairngormEvent subclasses that have this callbacks:Callbacks
property. Callbacks are just a couple of functions packed together (under an
agreed interface (mx.rpc.IResponder)) that the command, which was triggered by
the event, can *call back* when it's done (or if it has failed)... letting
know however actually was behind that callback object what happened. (From
the flexcoders.com interview it seems that these were built to be able to let
know the view that dispatched the event the result of the call without having
to clutter the model with unnecesary data that was only going to be used to
let that original view know what had happened anyways.)

When you define and EventGenerator, you set the list of events you want to be
dipatched. when you fire it off, the EventGenerator will take the first one,
will set it's callbacks properties so that it (the EG) will know when the
command is done, and the will dispatch it. If the EG is set to run in
sequence, it will then wait for the command associated with the event to run
the callback that lets it know that it can then run the next command; It'll
then run it, and so on until it runs out of events.

One can find, in a comment that doesn't show on the asdocs, the AS example
provided by the author (there's another that uses mxml notation and
preinstantiated events):

<quote><code>
// If any task/event fails, then abort the task processing entirely
(e.g. trigger == "0")
var parallelEvents :Array = [LoadUserProfileEvent,LoadMetaDataEvent];
var parallelGen :EventGenerator = new
EventGenerator(parallelEvents,null,0,"parallel");

// Now, manually add the parallel generator into the list for the
consecutive generator...
var consecutiveTasks : Array = [LoadBundleEvent,
parallelGen, LoadUserPreferencesEvent];

var handlers : CallBacks = new
Callbacks(whenAppIsReady, notifyUserOfError);
var cmd : EventGenerator = new
EventGenerator(consecutiveTasks,handlers,0);
cmd.dispatch();
</code></quote>

For this to work, you have to make sure that, from the command that might be
run from an event generated by this EventGenerator, once it is done, you call
the appropriate callback on the event or else the EventGenerator will just sit
there waiting forever. You can do something along these lines:

if (_yourTypedUMEvent.callbacks) _yourTypedUMEvent.callbacks.result(null);
// or _yourTypedUMEvent.callbacks.fault(info); // if something went wrong.

Please note that it seems that this was designed with asynchronous commands in
mind only; if you run a command that can send a result right away, you might
get a racing condition bug which will produce a runtime error.

EventGenerator will take UMEvent classes, instance or other EventGenerators,
so you can nest them in arbitrarily interesting ways. Pretty cool.

--
gabriel montagné láscaris comneno
http://rojored.com
t/506.8392.2040


Mon Apr 14, 2008 12:55 am

gabriel.mont...
Offline Offline
Send Email Send Email

Forward
Message #109901 of 150922 |
Expand Messages Author Sort by Date

Hi, I am trying to create a modular application in a way that each module has it's own MVC architecture (cairngorm) and is independent of the application. I've...
João
joaoak
Offline Send Email
Apr 11, 2008
12:42 am

... I've been looking into the Universal Mind extensions over the last couple of days and am implementing parts in my current project. They seem to be well ...
Douglas McCarroll
douglasmccar...
Offline Send Email
Apr 11, 2008
2:25 am

Its not really part of UM Cairngorm but the key to using Cairngorm with modules is that the base app, each module, and a library project referenced by all of...
ben.clinkinbeard
ben.clinkinb...
Offline Send Email
Apr 11, 2008
3:21 am

Ben, but that would mean that I would have a lot of code duplicated for each module, right? In this case, the cairngorm source (or, at least, the singletons)....
João
joaoak
Offline Send Email
Apr 11, 2008
10:01 am

Well, they would all point to the same Cairngorm/UM Cairngorm SWC (that lives in the library project) but yes, you would have a model, services, etc in each...
ben.clinkinbeard
ben.clinkinb...
Offline Send Email
Apr 11, 2008
12:52 pm

After joining UM and working with this I found the most kewlest slick part I like is the callback support in Cairngorm events. Uber sweet at helping you ...
Douglas Knudsen
dtk_atl
Offline Send Email
Apr 11, 2008
1:41 pm

I like the fact that someone found this to be a problem and cared to make this as a framework. When, I needed this, I was writing my custom code. But, I do not...
ACE
acer_u_will_...
Offline Send Email
Apr 11, 2008
3:02 pm

Hi Ace, I think your complaint is having to create a callback for every event/command invoked by your view and it is possible to avoid that. If thats not what...
ben.clinkinbeard
ben.clinkinb...
Offline Send Email
Apr 11, 2008
4:57 pm

Ben, Question for you. I've been looking at the UM extensions as well. How about your support for chaining? From what I've seen it's chaining commands, not...
Jon Bradley
jonpixelpusher
Offline Send Email
Apr 11, 2008
5:03 pm

Hi Jon, I don't really know what you mean by chained events, can you elaborate? I should also point out I have only been using UM Cairngorm for a couple of...
ben.clinkinbeard
ben.clinkinb...
Offline Send Email
Apr 11, 2008
6:56 pm

... Actually, I think it is chaining commands I need. Just looking to do it in a much easier fashion so that I can keep the same commands that can be used by...
Jon Bradley
jonpixelpusher
Offline Send Email
Apr 11, 2008
7:19 pm

Jon, regarding chain events, I use modular which allows this ( in fact thanks to Bjorn Schultheiss ). All you have to do is to have your events extend ...
João Fernandes
joao_m_ferna...
Offline Send Email
Apr 11, 2008
7:28 pm

http://code.google.com/p/flexcairngorm/ from the home page there is "Implementation of EventGenerator to allow developers to automate dispatching of sequences...
Douglas Knudsen
dtk_atl
Offline Send Email
Apr 11, 2008
8:29 pm

Good stuff indeed. Thanks for the links. I've actually grabbed that stuff and started to look into it a bit deeper. cheers, jon ... Good stuff indeed. Thanks...
Jon Bradley
jonpixelpusher
Offline Send Email
Apr 11, 2008
8:37 pm

It is not so much of using If/new callbacks, it is more of a generic approach. I personally do not like If(s), not a fan at all. What I find missing is an easy...
ACE
acer_u_will_...
Offline Send Email
Apr 13, 2008
12:14 pm

You don't like if statements? There is another thread around here about sequencing events/commands and there is also Cairngorm's SequenceCommand (though...
ben.clinkinbeard
ben.clinkinb...
Offline Send Email
Apr 13, 2008
1:54 pm

BTW, the EventGenerator class in the UM extensions is specifically for sequencing events. You can wrap a bunch of events in the EventGenerator and tell the...
Doug McCune
dougmccune
Offline Send Email
Apr 13, 2008
4:50 pm

Nice...seems like lack of documentation/examples is making me jump the gun. I will go into isolation and go through the library and see if this really takes...
ACE
acer_u_will_...
Offline Send Email
Apr 14, 2008
10:30 am

... Yeah, on has to go over the code a bit to see how it works, but that EventGenerator is pretty flexible and easy to use once you understand how the...
gabriel montagné
gabriel.mont...
Offline Send Email
Apr 14, 2008
10:31 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help