Reputation: 11
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
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
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