Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

"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 manerafor this, we have the following solution.

Every function listed for our Integra Framework works like this:

Code Block
languagejava
themeMidnight
function functionName(){
	UC_get(sqlquery,dsn,callback);
}

function callback(){
	//code
}

Lo anterior se ha simplificado a lo siguiente, utilizando funciones asyncThe above has been simplified to the following, using async functions:

Code Block
languagejavathemeMidnight
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 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:

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

...