Hi Neil,
I haven't got round to fleshing out all the documentation yet, but for the most part you can just use plain classes as config files in RL2:
class SomeConfig {
[Inject] public var something:Something;
[PostConstruct]
public function config():void
{
something.doStuff();
}
}
But, I might well be misunderstanding what you're wanting to do.
IContextConfig is only needed when you want more control. It allows you to hook in to the initialization process (actually, the whole context lifecycle) and possibly suspend and resume the flow:
class AsyncConfig implements IContextConfig {
public function configureContext(context:IContext):void
{
if (context.initialized)
throw new Error("This config must be installed prior to context initialization");
context.addStateHandler(ManagedObject.PRE_INITIALIZE, handleContextPreInitialize);
context.addStateHandler(ManagedObject.POST_INITIALIZE, handleContextPostInitialize);
}
private function handleContextPreInitialize(step:String, callback:Function):void
{
trace("Doing some things before the context self initializes...");
setTimeout(callback, 1000);
}
private function handleContextPostInitialize():void
{
trace("Doing some things now that the context is initialized...");
}
}
Whenever a state handler accepts a callback the flow is suspended until the handler calls back (possibly with an error). It's worth noting that such a config will not be injected into, and that the context may still be uninitialized.
However, if you don't need this kind of fine-grained control, you can just pass a plain config class. Before context initialization all plain config classes are queued when installed. They are processed as a batch when the context initialises. Configs installed after initialization are processed immediately. This is all handled by the config manager. You can also write your own config handlers. For more info on how configs are processed see:
Hope that helps. Lemme know if I missed the point :)