Node.js Zamanlayıcı Modülü
Örnek
Her 500 milisaniyede bir "Merhaba" yazın:
var myInt = setInterval(function () {
console.log("Hello");
}, 500);
Tanım ve Kullanım
Zamanlayıcılar modülü, belirli bir zamanda daha sonra çağrılacak bir yol zamanlama işlevleri sağlar.
Timer nesnesi, Node.js'deki global bir nesnedir ve anahtar kelimeyi kullanarak içe aktarmak gerekli değildir require
.
Zamanlayıcı Yöntemleri
Method | Description |
---|---|
clearImmediate() | Cancels an Immediate object |
clearInterval() | Cancels an Interval object |
clearTimeout() | Cancels a Timeout object |
ref() | Makes the Timeout object active. Will only have an effect if the Timeout.unref() method has been called to make the Timeout object inactive. |
setImmediate() | Executes a given function immediately. |
setInterval() | Executes a given function at every given milliseconds |
setTimeout() | Executes a given function after a given time (in milliseconds) |
unref() | Stops the Timeout object from remaining active. |