private function foo_1():void { // code here foo_2(param); } private function foo_2(param:Object):void { // code here foo_3(param, param2); } // etc
public function init():void { Async.instruction .add(commandOne, 'Param for commandOne') .add(commandTwo, 100500) .add(commandThree, [1, 2, 3, 4, 5]) .execute(finalCommand, 'instruction executed successfully'); } private function commandOne(completeCb:Function, string:String):void { trace(string); // 'Param for commandOne' completeCb(); } private function commandTwo(completeCb:Function, number:int):void { trace(number); // 100500 completeCb(); } private function commandThree(completeCb:Function, array:Array):void { trace(array); // [1, 2, 3, 4, 5] completeCb(); } private function finalCommand(input:String):void { trace(input); // 'instruction executed successfully' }
public function init():void { Async.instruction.add(commandOne) .add(commandTwo, 100500) .add(commandThree, { type:'init data' } ) .executeCollectingHeap(finalCommand); } private function commandOne(completeCb:Function):void { completeCb('commandOne', '1'); } private function commandTwo(completeCb:Function, number:int):void { trace(number); // 100500 completeCb('commandTwo', 2); } private function commandThree(completeCb:Function, object:Object):void { trace(JSON.stringify(object)); // { type:'init data' } completeCb('commandThree', {type:3}); } private function finalCommand(heapResult:Array):void { trace(heapResult[0]); // ['commandOne', '1'] trace(heapResult[1]); // ['commandTwo', 2] trace(heapResult[2]); // ['commandThree', {type:3}] trace('Instruction with heap executed successfully'); }
public function init() { Async.order .add(commandOne) .add(commandTwo) .add(commandThree) .execute(finalCommand); } private function commandOne(completeCb:Function):void { completeCb('string from commandOne'); } private function commandTwo(completeCb:Function, string:String):void { trace(string); // string from commandOne completeCb(2, 'string from commandTwo'); } private function commandThree(completeCb:Function, number:int, string:String):void { trace(number); // 2 trace(string); // string from commandTwo completeCb(); } private function finalCommand():void { trace('Order completed'); }
Source: https://habr.com/ru/post/212521/