Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function buyPackage():Promise<String>
- {
- /**
- var transaction = _buyPackage(model.packageId);
- transaction.handle(function(v:Outcome<String, Error>) {
- // TODO: Bad way for calling strategy. Proper way is rework BuyCreditAlertFinishAdapterStrategyMacro and all mactro/comands which using in it, and after it use @Map
- var m = new CommandMapping(BuyCreditAlertFinishAdapterStrategyMacro);
- new CommandExecutor(injector, module).executeCommand(m);
- });
- return transaction;
- */
- var transaction = _buyPackage(model.packageId);
- transaction.flatMap(function(v:Outcome<String, Error>) {
- switch(v){
- case Outcome.Success(result):
- return Future.async( function(trigger) {
- var m = new CommandMapping(BuyCreditAlertFinishAdapterStrategyMacro);
- m.withCompleteHandler(function(command:IAsyncCommand){
- trigger(Outcome.Success(result));
- });
- m.withFailHandler(function(command:IAsyncCommand){
- trigger(Outcome.Failure(new Error("Macro failed BuyCreditAlertFinishAdapterStrategyMacro")));
- });
- new CommandExecutor(injector, module).executeCommand(m);
- };
- case Outcome.Failure(error):
- return Future.sync(v);
- }
- });
- return transaction;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement