passing events between contexts?

Gerry Koh's Avatar

Gerry Koh

01 Oct, 2010 01:36 AM


i have a project called Wrapper that stages a Player and a Playlist. Player and Playlist are separate projects with their own contexts, etc.

i am looking for advice on how to let the Playlist send events that the Player captures. Eventually i was thinking about a PlayerControlService and a PlaylistControlService but for now just need to get the two projects to communicate.

I tried firing an event in one project and listening for it in the other but that didn't work (at least the first try :) So I'm assuming that each event bus is separate.

Is there a best practice for this sort of thing? I know I can use bubbling events to go up to the wrapper and back down to the desired target, but I'm trying to stick to one event bus where possible.



  1. Support Staff 1 Posted by Shaun Smith on 01 Oct, 2010 07:12 PM

    Shaun Smith's Avatar

    Hi Gerry,

    One way is to leave the contexts as they are (with separate event buses), and pass in a third Event Dispatcher that they can talk through.

    var sharedDispatcher:IEventDispatcher = new EventDispatcher();
    player = new Player(sharedDispatcher);
    playlist = new Playlist(sharedDispatcher);

    You'd need to pass the shared event dispatcher through to each context and map it into each injector.

    There are plenty other ways to do it - using a modular utility for example - but the approach above is probably the simplest for the job at hand.

    Hope that helps!

  2. 2 Posted by Gerry Koh on 01 Oct, 2010 09:45 PM

    Gerry Koh's Avatar

    Thanks Shaun! I will also have the opportunity to spend more time on this part soon, I would love any other suggestions that you might personally prefer.

  3. 3 Posted by Stray on 03 Oct, 2010 10:58 AM

    Stray's Avatar

    Check out the old version of robotlegs modular (on my fork at ) for the old-skool way of wiring contexts together - it will make obvious most of the 'gotcha' stuff.

  4. 4 Posted by Gerry Koh on 06 Oct, 2010 04:50 PM

    Gerry Koh's Avatar

    thanks stray, i'll check it out now.

  5. 5 Posted by Gerry Koh on 14 Oct, 2010 11:16 PM

    Gerry Koh's Avatar


    do you have any examples of mapping an additional context into an injector? i'm not sure of the syntax to do this.

  6. Gerry Koh closed this discussion on 22 Oct, 2010 10:28 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac