Which I found whilst trying to modify the code for another feature.
So the ViewComponent get's mapped for the mediator. But it's actaully exposed to the entire injector for a bit longer than expected. So you can inject the view component whilst in the 'preInitialize', 'initialize' and 'postInitialize' phase.
For example you can do the following which should cause errors when injecting.
class ExampleConfig
{
[Inject]
public mediatorMap:IMediatorMap;
[Inject]
public commandMap:IEventCommandMap;
[Inject]
public injector:IInjector;
public function config():void
{
mediatorMap.map(ExampleView).toMediator(ExampleMediator);
commandMap.map(ExampleEvent.TRIGGER_COMMAND).toCommand(ExampleCommand);
injector.map(IExampleService).toType(ExampleService);
}
}
class ExampleMediator
{
public function initialize():void
{
dispatchEvent(new ExampleEvent(ExampleEvent.TRIGGER_COMMAND));
}
}
class ExampleCommand
{
[Inject]
public service:IExampleService;
[Inject]
public viewComponent:ExampleView;
public function execute():void
{
trace(viewComponent + " is not null");
}
}
class ExampleService implements IExampleService
{
[Inject]
public viewComponent:ExampleView;
[PostConstruct]
public function init():void
{
trace(viewComponent + " is not null");
}
}
Let me know if this is a hidden feature that isn't documented, or a bug and I'll fix :godmode:
Currently there is a hidden feature due to this line in MediatorFactory.as:
Which I found whilst trying to modify the code for another feature.
So the ViewComponent get's mapped for the mediator. But it's actaully exposed to the entire injector for a bit longer than expected. So you can inject the view component whilst in the 'preInitialize', 'initialize' and 'postInitialize' phase.
For example you can do the following which should cause errors when injecting.
Let me know if this is a hidden feature that isn't documented, or a bug and I'll fix :godmode: