Clarifications on how Edmund operates

12 views
Skip to first unread message

Thomas Messier

unread,
Nov 22, 2008, 9:05:10 PM11/22/08
to edmund-coldfusion
I was wondering if somebody could shed light on exactly how Edmund is
supposed to be used. I'll clarify my understanding of event-driven and
how I've seen it implemented first to give some background as to my
doubts. I'm more familiar with an Observer type pattern, where you can
extend an Observable class that has methods like addEvent(), fireEvent
(), and addListener(). So I could have a Task component, and upon
initializing it I would have something like this.addEvent("complete").
Then, inside the complete() method, I would have a line at the end
that would do this.fireEvent('complete', ...relevant arguments
here...) . Having that set up, listeners can be added whenever a task
object is instantiated. So somebody would do as follows:

task = createObject("component", "task");
task.addListener("complete", obj, method, args);


So now, when I look at the edmund implementation and sample code, I
feel like I'm missing something. In the sample app I see something
like this:

application.edmund.register("one", createObject
("component","logger").init("child:1"));
application.edmund.dispatch("one");

Looking at this, it appears that register() is the equivalent of my
addEvent() and dispatch() is the equivalent of my fireEvent(). But
where's the equivalent of the addListener() ?

I have a feeling it's something really silly I'm just not getting, or
maybe I'm comparing apples and oranges here. Maybe I'd appreciate it
if somebody could shed some light on this, I'd appreciate any input.

Adam Haskell

unread,
Nov 23, 2008, 9:36:04 PM11/23/08
to edmund-c...@googlegroups.com
Now everything I say could be entirely null and void as soon as Sean responds back and says I am an idiot so take this at face value (mind you Sean and I have been on the same wave length before, rare but it happens ;) ). Take a step back on think more simplistically for a second and I think it will all work out for you ;) All Edmund does is keep track of anything listening for an event and then if that event is fired it makes sure all those somethings get notified of the event. Basically to edmund register implicitly does addEvent should it not exist then it adds a listener to said event.

So when I ask Edmund to register  (rgister("complete" myObject, "myResponseFunction", true) ) I am saying hey Edmund, sooner or later I am hoping "complete" happens. When it does please fire off "myResponseFunction" on myObject, oh and while you're at it just do it whenever on a different thread. K, thanks bye.

Alternately you can create a listener object for Edmund and pass that in to register (I've been tinkering with this for Fusebox's lifecycle).

Dispatch on the other hand (dispatch("complete")) you are asking Edmund, Hey Edmund if you could search around your internals and find anything that is listening for a complete event and fire it off I'd appreciate it...let me know when you're done I got other stuff to do bro.


Now Edmund goes a step further with the simple workflows and async sugar and spice but at the heart it is just a queue of listeners wait for a dispatch(). 


Adam

Thomas Messier

unread,
Nov 25, 2008, 12:16:14 AM11/25/08
to edmund-c...@googlegroups.com
Thanks Adam, I knew it was something simple. I think I got a little confused because the example just does the register() and dispatch() one after the other, which isn't too common. But it all seems to make sense now!
 
-TM


From: edmund-c...@googlegroups.com [mailto:edmund-c...@googlegroups.com] On Behalf Of Adam Haskell
Sent: Sunday, November 23, 2008 9:36 PM
To: edmund-c...@googlegroups.com
Subject: [edmund-coldfusion] Re: Clarifications on how Edmund operates

Sean Corfield

unread,
Nov 27, 2008, 8:56:00 PM11/27/08
to edmund-coldfusion
On Sat, Nov 22, 2008 at 6:05 PM, Thomas Messier
<thomas....@gmail.com> wrote:
> doubts. I'm more familiar with an Observer type pattern, where you can
> extend an Observable class that has methods like addEvent(), fireEvent
> (), and addListener(). So I could have a Task component, and upon
> initializing it I would have something like this.addEvent("complete").

What does addEvent() do? I can't imagine that use case.

> task = createObject("component", "task");
> task.addListener("complete", obj, method, args);

If task extends edmund.Edmund, that works (use addEventListener() or
register() to add the handler). Then you can say
task.dispatch("complete"). Otherwise Edmund stands "aside" from those
components as an event bus and you add listeners / dispatch events
directly via Edmund. You can

> Looking at this, it appears that register() is the equivalent of my
> addEvent() and dispatch() is the equivalent of my fireEvent(). But
> where's the equivalent of the addListener() ?

No, register() is addEventListener(). I've no idea what your addEvent() is.
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

Thomas Messier

unread,
Nov 27, 2008, 9:28:49 PM11/27/08
to edmund-coldfusion
addEvent() just defines what events you can create a listener for. I see how
it's not absolutely necessary, I guess it's sometimes used just to make it
clear in one place what events you can add listeners for. An example of that
kind of implementation is Ext JS, the Observable class which is extended by
most components has an addEvents() function that takes n arguments for event
names. And I do get that register() is addEventListener(), not sure why I
would have written addEvents().

Thanks for the clarification!

-TM

-----Original Message-----
From: edmund-c...@googlegroups.com
[mailto:edmund-c...@googlegroups.com] On Behalf Of Sean Corfield
Sent: Thursday, November 27, 2008 8:56 PM
To: edmund-coldfusion
Subject: [edmund-coldfusion] Re: Clarifications on how Edmund operates


Reply all
Reply to author
Forward
0 new messages