(This tag must be placed inside an <EventMap> tag)
An Injectors tag defined in the Event Map is a container for InjectorPropertys that will inject properties coming from a source to a target, but they can also be used for other purposes.
<Injectors target="{MyTargetClass}">
...
</Injectors>
The Injectors tag are similar to the EventHandlers, and when executed, they will run all inner tags in order. EventHandlers are executed when an event of the matching type is dispatched. Injectors, on the other hand, are executed when an object of the class defined in the target attribute is created. In order for the Injectors to run, the object of that class needs to be created within the display list, or be instantiated by the ObjectBuilder or MethodInvoker tags.
Attributes
target
Class
required
The class that, when instantiated, should trigger the inner tags to run. This target must be supplied using bindings, but this binding is only executed once, when the event map is created.
includeDerivatives
Boolean
If true, then subclasses of specified class will also trigger injection. If specified class is an interface, then classes implementing interface will trigger injection. If false, only instances of the specific class will trigger inner tags to run. Default is false.
debug
Boolean
Whether to show debugging information for this Injectors block. If true, Console output will show debugging information as the injectors are applied.
start
Event handler
In the start attribute you can supply an event handler for the event of
type ActionListEvent.START. This event is dispatched right before the actions (normally PropertyInjector items)
are called, when the list starts execution.
Example:
<Injectors target="{MyTargetClass}" start="trace('Execution of injectors list started!')">
...
</Injectors>
end
Event handler
In the end attribute you can supply an event handler for the event of type ActionListEvent.END.
This event is dispatched right after all the items in the list have been executed.
Example:
<Injectors target="{MyTargetClass}" end="trace('Execution of injectors list ended!')">
...
</Injectors>
Inner tags
PropertyInjector
PropertyInjector s defined in the Injectors tag will apply or bind properties specified in the source to the target specified in the parent Injectors target. See more information in the PropertyInjector documentation.
ListenerInjector
A ListenerInjector tag will add an event listener for a specific event type and call the specified method on the target specified in the parent Injectors target. See more information in the ListenerInjector documentation.
Other tags
All other tags allowed inside EventHandlers and MessageHandlers are allowed inside the Injectors. This allows you to inject other properties to the target, such as data coming from a server call (one-time only).
I understand needing an explicit getter and setter when you're doing more than just moving properties from the business logic to the view, but most of the time that's all I'm doing. Having to define code like this:
[Bindable (event="heightChange")]
public function get main_image_height():Number
{
return _main_image_height;
}
public function set main_image_height(h:Number):void
{
_main_image_height = h;
dispatchEvent( new Event('heightChange'))
}
instead of just something like this:
public [Bindable] main_image_height (need that event communication though...)
is really painful.
I need to dig in your code and see if I can contribute a solution to my problem, but I figured I would see if I'm just missing something here (I only started playing with Mate yesterday).
Keep up the great work. Mate looks to be shaping up to be my framework of choice.
setters and getter are the equivalent to a property. Nowhere here it says that you have to use getters and setters. The targetKey for PropertyInjectors needs just to be a public property, which doesn't even need to be bindable. How you expose that property (via a public property or via setters) is up to you.
You can see an example of that here: http://mate.asfusion.com/assets/content/examples/stockQuoteExample/srcview/
I know this section of the docs is a little thin, so that is probably why you are missing that piece. I am working on writing more for this.
If you have more questions, please refer to the forums.
Thanks!
You documentation is difficult to understand. Do you mean
start="handlerMyEventHandler"
or
start="ActionListEvent.START"