Juan Pieterse
Posts: 0
Joined: Sat Apr 25, 2015 1:47 pm

Service Execution order

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??

Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

Service Execution order

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

Juan Pieterse
Posts: 0
Joined: Sat Apr 25, 2015 1:47 pm

Service Execution order

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?

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Service Execution order

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

Return to “Issues”