Skip to content

Instantly share code, notes, and snippets.

@creynders
Created September 19, 2011 11:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save creynders/dc189fb124b4cc1062fc to your computer and use it in GitHub Desktop.
Save creynders/dc189fb124b4cc1062fc to your computer and use it in GitHub Desktop.
Using the responder directly
/* EXAMPLE OF USING THE RESPONDER DIRECTLY */
//IConfigDataRetrieverService
function retrieveConfigData():ISignalResponder;
//XMLLoaderConfigDataRetrieverService
private var _loader : XMLLoader;
public function retrieveConfigData() : ISignalResponder{
var request : URLRequest = new URLRequest( 'config.xml' );
_loader = new XMLLoader( request )
return _loader.responder;
}
//RetrieveConfigDataCommand
[Inject]
public var configDataRetrieverService : IConfigDataRetrieverService
public function execute() : void{
commandMap.detain( this );
var responder : ISignalResponder = service.retrieveConfigData();
responder.successSignal.addOnce( _handleConfigDataSuccessSignal );
responder.failureSignal.addOnce( _handleConfigDataFailureSignal );
}
private function _handleConfigDataSuccessSignal( xml : XML ) : void{
//do stuff with xml
commandMap.release( this );
}
private function _handleConfigDataFailureSignal() : void{
var mailer : AS3Mailer = new AS3Mailer();
mailer.send("buggyapplication@somewhere.com", "crappydeveloper@somewhere.com", "Dear Crappy Developer", "You suck!");
commandMap.release( this );
}
//And again, we could swap the implementation of IConfigDataRetrieverService to another one
//not using AssetLoader
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment