-
-
Save creynders/dc189fb124b4cc1062fc to your computer and use it in GitHub Desktop.
Using the responder directly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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