/
Async Await

Async Await

"LaterĀ doesn't happen strictly and immediately afterĀ now", for this, we have the following solution.

Every function for our Integra Framework works like this:

function functionName(){ UC_get(sqlquery,dsn,callback); } function callback(){ //code }

This as been simplified as shown next, usingĀ async functions: (same function names with _async)

async function functionName(){ let resp = await UC_get_async(sqlquery,dsn); //code }

AwaitĀ specifies that the used function must return something before continuing with the block of code that follows.

Practical 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 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"); } }



Related content

Async Await.
More like this
Async Await.
More like this
Async Await.
More like this
Async Await.
Async Await.
More like this
b. Integra Framework
b. Integra Framework
More like this
Integra Framework
Integra Framework
More like this