loading table of contents...

5.5.3. Annotations of Context Consumer and Context Provider

Instead of passing the state configuration from the container down to the child component Studio IoC requires that context providers and consumers declare themselves as provider or consumer and in which context they are interested in.

Assume that you have a property exampleProperty of a context consumer exampleConsumer and want to inject a provided property to the example property. The setter method of the property in the class exampleConsumer must be annotated:

[InjectFromExtParent]
public function setExampleProperty(value:String):void {
  exampleProperty = value;
}

The Studio Component IoC generates the name of the provided property out of the annotated method name. This annotation is called implicit. In the example the assumed name of the provided property is exampleProperty. But in most cases the method name will not reflect the name of the provided property. Hence, the annotation supports the optional parameter variable:

[InjectFromExtParent(variable='providedProperty')]
public function setExampleProperty(value:String):void {
  exampleProperty = value;
}

This annotation is called explicit. The name of the provided property in the example is then providedProperty. Still, the annotation is not flexible enough if you want to reuse exampleConsumer and to configure the name of the provided property. The optional parameter variableNameConfig does the job:

[InjectFromExtParent(variableNameConfig='examplePropertyVariableName')]
public function setExampleProperty(value:String):void {
  exampleProperty = value;
}

This annotation is called configurable. Then in order to inject the provided property, the name of the provided property has to be configured explicitly for each consumer in the EXML:

<editor:contextConsumer examplePropertyVariableName="providedProperty"/>

The annotation of a context provider is done in similar way but will not be described in details here. To customize Studio you only need to know how to inject a provided property and which (and where) provided properties exist. Section 7.8, “Customizing Studio using Component IoC” describes how to customize Studio using the Studio component IoC.