nativescript
Variables globales
Buscar..
Consola
La variable de console global de NativeScript le permite imprimir valores en su terminal para la depuración. El uso más simple es pasar un valor a la función console.log() :
console.log("hello world");
El objeto de console tiene varios otros métodos, incluidos dump() , trace() , assert() y más .
// Prints the state of a full object.
console.dump({ firstName: "Native", lastName: "Script"});
// Prints the current stack trace
console.trace();
// Asserts a boolean condition, and prints to the console if the assertion fails.
console.assert(1 === 1, "This won’t print as the condition is true");
console.assert(1 === 2, "This will print as the condition is false");
Temporizador (JavaScript)
La variable de timer global de NativeScript le permite establecer tiempos de espera e intervalos para llamadas de función retardadas asíncronas.
Importador
var timer = require("timer")
Tiempos de espera
var callback = function(){
console.log("I will be executed once after 500ms");
}
var timeoutId = timer.setTimeout(callback, 500);
// clearing the timeout
timer.clearTimeout(timeoutId);
Intervalos
var callback = function(){
console.log("I will be executed every 500 ms")
}
var intervalId = timer.setInterval(callback, 500);
// clearing the interval
timer.clearInterval(intervalId);
Modified text is an extract of the original Stack Overflow Documentation
Licenciado bajo CC BY-SA 3.0
No afiliado a Stack Overflow