Modules & StageSyncExtension

34 views
Skip to first unread message

Adnan Doric

unread,
Feb 10, 2012, 11:45:24 AM2/10/12
to robo...@googlegroups.com
Hi group,

I noticed a possible weird behavior when using Modules with RL2:
Sometimes Flex is reparenting modules so the event REMOVED_FROM_STAGE is dispatched immediately followed by ADDED_TO_STAGE when for example changing focus between modules. This is of course enough for StageSyncExtension to destroy the module's Context.

I'm also manually injecting the view as there is no ViewMap (yet?), so basically I'm calling injector.injectInto(module) as soon as the module is added to stage in order to instantiate its Context.

So what you think about this?

Adnan Doric

unread,
Feb 11, 2012, 8:01:05 AM2/11/12
to robo...@googlegroups.com
I found a way to be able to re-create the module context after its destruction by using the ElementExistenceEvent.ELEMENT_ADD event in the module container, this way I don't have to keep the reference to the module itself.
Still searching for a better way if possible, I'll keep you informed if I come up with something better.

Cheers,
Adnan
--
You received this message because you are subscribed to the Google
Groups "Robotlegs" group.
To post to this group, send email to robo...@googlegroups.com
To unsubscribe from this group, send email to
robotlegs+...@googlegroups.com
for support visit http://knowledge.robotlegs.org

Shaun Smith

unread,
Feb 14, 2012, 11:36:11 AM2/14/12
to robo...@googlegroups.com
Hey Adnan,

Sorry for the delay - busy with work. This is something we'll need to solve before release. Please could you post an issue on the tracker:


so we can track it. This kind of issue affects more than just that specific extension.. We'll probably need a strategy for suspending/resuming things across the entire framework as so many things are display list driven.

Thanks,

Shaun Smith

unread,
Feb 14, 2012, 11:38:25 AM2/14/12
to robo...@googlegroups.com
Just wondering why you need the ViewMap here? Why do you need to injectInto the module? Does the Modularity extension not work for your purposes?

Adnan Doric

unread,
Feb 15, 2012, 10:07:03 AM2/15/12
to robo...@googlegroups.com
I wanted to inject the module context in it upon its creation, probably a mistake as I never found an example with modularity for RL2.

1) I wait for the container's ElementExistenceEvent.ELEMENT_ADD
2) then I inject into it using the good old: injector.injectInto(event.element)
3) knowing that the module has a setter parentInjector(value:Injector) annotated with [Inject] I use it to instantiate a new ModuleContext(this). I'm not using the value (Injector) at all, it just does the job creating the new context as you can see. The ModuleContext class contains the custom config class (ModuleConfig) so I can configure the context the way I want:
4) ModuleConfig.configure():
            mediatorMap.mapView(ICustomModule).toMediator(ModuleMediator);
            mediatorMap.handleView(contextView, ICustomModule);


I map the interface to mediator and than manually trigger the mediator creation.

I'm still trying to figure out how to use it properly, but at least the ScopedEventDispatcherExtension is working between shell/modules and for the rest, maybe you can help me find THE Way :)

What I need is pretty simple:
    - be able to create multiple module instances (same or different classes)
    - each one having its own custom context config
    - having a mediator for the whole module (main module class)
    - be able to mediate separately some views in it

So maybe you are right and there is no need for the ViewMap at all, I just need to figure out how to assemble the puzzle.

Cheers,
Adnan
Reply all
Reply to author
Forward
0 new messages