Title: Mediators adding their own View Components Post by: caista on August 31, 2011, 06:22:40 Hello
Now I know this can be done and is not bad practice, but I can't work out how to do it. Obviously a Mediator can be registered without a viewComponent. But then say I want the mediator to respond to a Notification and add it's own viewComponent, how would it do this? It won't have any reference to a DisplayObject to add the viewComponent to. I hope this makes sense. I have searched the forum and can't find a simple answer to this. Thanks in advance Title: Re: Mediators adding their own View Components Post by: puremvc on August 31, 2011, 08:16:29 Have it respond to a notification by instantiating the view component, setting its own reference to that view component and then send it off in another notification that a StageMediator (or the appropriate mediator whose view component you want to inject this one into) hears. The StageMediator might listen for an ADD_TO_STAGE notification, for instance, and respond by taking the component out of the note, cast to DisplayObject and do an addChild on its Stage reference.
Title: Re: Mediators adding their own View Components Post by: caista on September 01, 2011, 07:30:42 OK, brilliant thanks.
Presumably I could use the ApplicationMediator rather thatn creating a StageMediator. Title: Re: Mediators adding their own View Components Post by: puremvc on September 01, 2011, 07:53:18 Yep, that'll usually do.
|