AnsweredAssumed Answered

Portal.queryItems callback function execution timing

Question asked by nart.tamash on May 11, 2016
Latest reply on May 11, 2016 by nart.tamash

Hi all,


I've got the following scenario...I'm querying my local Portal for certain items and then I am processing them using a callback function, as soon as the query returns them.



     function doSomeOtherStuff() {
          //do some other stuff
          //requires the updated globalVariable


     function processItems(items) {
          //do something
          //update globalVariable



Giving this is an async call, other things (i.e. doSomeOtherStuff()) carry on while the query is finalised and the items processed.


How can I wait for the processItems() to complete before doing anything else (so a synchronous operation in a sense)?

The processItems function updates a global variable that I need to use in doSomeOtherStuff() and carry on with the logic. I can't execute doSomeOtherStuff() within processItems() because due to the nature of it, it will take doSomeOtherStuff() out of scope.


Hope this makes sense, I've tried to simplify as much as possible.