or Create a profile
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.
2 Posted by Shaun Smith on 01 Oct, 2010 07:12 PM
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!
3 Posted by Gerry Koh on 01 Oct, 2010 09:45 PM
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.
4 Posted by Stray on 03 Oct, 2010 10:58 AM
Check out the old version of robotlegs modular (on my fork at github.com/stray ) for the old-skool way of wiring contexts together - it will make obvious most of the 'gotcha' stuff.
5 Posted by Gerry Koh on 06 Oct, 2010 04:50 PM
thanks stray, i'll check it out now.
6 Posted by Gerry Koh on 14 Oct, 2010 11:16 PM
do you have any examples of mapping an additional context into an injector? i'm not sure of the syntax to do this.
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.
3 people watching.
No more actions from Robotlegs or the discussion starter are required.
This discussion is private.
Only you and Robotlegs support staff can see and reply to it.
This discussion is public. Everyone can see and reply to it.
Powered by Tender™.