/
Async Await.
Async Await.
"LaterĀ doesn't happen strictly and immediately afterĀ now", for this, we have the following solution.
Every function listed for our Integra Framework works like this:
function functionName(){
UC_get(sqlquery,dsn,callback);
}
function callback(){
//code
}
The above has been simplified to the following, using async functions:
async function functionName(){
let resp = await UC_get_async(sqlquery,dsn);
//code
}
Await specifies that the detailed function returns something, and then continues with the block of code, the response delay should not be taken into account to continue the operation.
Example:
/**
* @name GET_MANAGEMENTS
* @desc This function gets the managements of a given client
*/
async function getManagements() {
let response = await UC_get_async("SELECT * FROM CEMEX_Managements WHERE client_id = " + selectedClient.id + " ORDER BY fecha DESC ", '');
return response;
}
/**
* @name MANAGEMENTS_AND_FILL
* @desc This function gets the managements of a given client and
* fills the info in the managements table
*/
async function getAndFillManagement() {
let response = await getManagements();
let managements = JSON.parse(response);
if (managements.length) {
managements = managements.map(management => {
if (management.date) {
management.date = moment(management.date).format('DD/MM/YYYY HH:mm:ss');
}
});
UC_fullTable('managementsTable', JSON.stringify(managements), 'date,agent,campaign,level1,level2,level3,coments', null, '110px', "DD/MM/YYYY HH:mm:ss", 0, "desc");
}
}
, multiple selections available,
Related content
Integra Framework
Integra Framework
More like this
Async Await
Async Await
More like this
Async Await.
Async Await.
More like this
Async Await.
Async Await.
More like this
Async Await.
Async Await.
More like this
b. Integra Framework
b. Integra Framework
More like this