サーチ…


コンソール

NativeScriptのグローバルconsole変数を使用すると、端末に値を出力してデバッグすることができます。最も簡単な使い方は、 console.log()関数に値を渡すことです。

console.log("hello world");

consoleオブジェクトには、 dump()trace()assert()などのいくつかのメソッドがあります

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

タイマー(JavaScript)

NativeScriptのグローバルtimer変数を使用すると、非同期の遅延関数呼び出しのタイムアウトと間隔を設定できます。

インポート

var timer = require("timer")

タイムアウト

var callback = function(){
    console.log("I will be executed once after 500ms");
}
var timeoutId = timer.setTimeout(callback, 500);

// clearing the timeout
timer.clearTimeout(timeoutId);

インターバル

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
ライセンスを受けた CC BY-SA 3.0
所属していない Stack Overflow