Skip to content

Instantly share code, notes, and snippets.

@benbjohnson
Created December 14, 2010 19:10
Show Gist options
  • Save benbjohnson/740901 to your computer and use it in GitHub Desktop.
Save benbjohnson/740901 to your computer and use it in GitHub Desktop.
Async Callback Test
public function shouldTestCallbackMethod():void
{
// Create a dispatcher that lives outside your callback
var dispatcher:EventDispatcher = new EventDispatcher();
// Create your callback mock function which dispatches the event
var func:Function = function():void{
dispatcher.dispatchEvent(new Event(Event.COMPLETE));
}
// Set the FlexUnit condition to wait for the dispatcher
Async.proceedOnEvent(this, dispatcher, Event.COMPLETE);
// Assign callback and run code
myObj.callback = func;
myObj.execute();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment