user2418920
user2418920

Reputation: 11

IBM WorkLight Studio Client Side Adapter Call

Will it be possible for the Worklight Adapter to be called synchronously?

This is the client code I am using:

function GetAccount(){
   var acctresponse;

   //Adapter call to get accounts from Server
   //Registered Onsuccess and OnFailure
   onSuccess: function(response){acctresponse=response},
   onFailure: function(error){acctresponse=null;}

   //UI Code dependent on above acctresponse.

}

Being Client adapter synchronous, the UI code is executed before the response arrives.

Can anyone suggest what is the best approach to handle a situation like this?

Upvotes: 1

Views: 452

Answers (2)

David Whitehouse
David Whitehouse

Reputation: 11

As was stated above the adapter calls are by nature asynchronous - as are many of the javascript APIs used in web and mobile development. To ensure that the UI code is only executed after the adapter call complets you should invoke it from the onSuccess callback function.

Upvotes: 1

Anton
Anton

Reputation: 3166

Request to adapter is issued using AJAX, which stands for Asynchronous JavaScript and XML. Therefore the answer is no since underlying transport layer is asynchronous.

Upvotes: 1

Related Questions