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.
globalVariable
//...
function doSomeOtherStuff() {
//do some other stuff
//requires the updated globalVariable
};
Portal.queryItems(params).then(processItems)
doSomeOtherStuff();
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.