Async Await.

"Later doesn't happen strictly and immediately after now", para ello, tenemos la siguiente solución.

Toda función listada para nuestro Integra Framework trabaja de esta manera:

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

Lo anterior se ha simplificado a lo siguiente, utilizando funciones async:

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

Await especifica que la función detallada devuelva algo si o si, para luego continuar con el bloque de código, no se deberá tener en cuenta la demora de respuesta para continuar con el funcionamiento. 

Ejemplo práctico:

/** * @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"); } }