Sure thing! Have a quick read through the MessageDispatcher:
When you implement IContextConfig you are able to grab the context and add message handlers for the various context lifecycle phases (as declared in ManagedObject). You can make a handler asynchronous by giving it an asynchronous signature:
function asyncHandler(phase:String, callback:Function):void
{
// store the callback
// do some async stuff
// if everything worked out, call callback() with no arguments
// if there was an error, pass that error to the callback: callback(error)
// note: you MUST call the callback at some point or the process will never complete
}
There is more info on the async conventions here:
So, one approach is to implement IContextConfig, but that's usually just for extensions and bundles. If you want to create your own kind of configuration mechanism you can register a config handler with the ConfigManager. A config handler allows you to define what happens when a particular type of object or class is installed into a context (via the context constructor or via context.require()).
You might decide to handle any object that implements a particular interface and do something with it:
context.addConfigHandler(
instanceOf(ISomeType),
function(instance:ISomeType):void {
// do something whenever an object of this type is "required"
});
As with any message handler, the config handler can be asynchronous by having an asynchronous signature.
However, you need to make sure that your config handler is installed before any configs it needs to process are installed. Therefore you'd create an extension to install the config handler and pass that extension to your context at construction time:
_context = new Context(
MyConfigHandlerExtension, // installs a config handler that processes ISomeType instances
new MySpecialConfig("param")); // an instance that implements ISomeType
Anyhoo, most of that stuff is for advanced usage (extension design). If you outline your use case I can see if there is a simpler way to do it.