Page 1 of 1

Service Execution order

Posted: Mon Oct 19, 2015 8:09 pm
by Juan Pieterse

Hi there!

i have the following in JS:
ServiceA.exeute();
ServiceB.execute();

ServiceA does a db query and stores a result in LocalStorage.
ServiceB uses the above mentioned LocalStorage to construct its own query.
But it seems that when I test the app and the JS executes, ServiceB seems
to execute at the same time as ServiceA, as it is still using the previous LocalStorage value (before it even got set by ServiceA)

Is there a way to ensure that one service executes after the other??


Service Execution order

Posted: Mon Oct 19, 2015 10:18 pm
by Bruce Stuart

Put the call to execute service B in the success or completion methods for service "a"


Service Execution order

Posted: Tue Oct 20, 2015 9:25 am
by Juan Pieterse

Not too sure it's the best way to go.. I've got lots of if x 0then execute serviceB else execute sericeA then serviceC type statements.. So it may become a bit messy if i add call services with services..
Is there no other way to ensure that one executes before the other?


Service Execution order

Posted: Tue Oct 20, 2015 7:09 pm
by Serhii Kulibaba

Hello, Juan

Bruce is right, if you want to run one service after other, you have to run service B on the service's A success event