Mô-đun hẹn giờ Node.js

❮ Mô-đun tích hợp


Thí dụ

Viết "Xin chào" cứ sau 500 mili giây:

var myInt = setInterval(function () {
    console.log("Hello");
}, 500);

Định nghĩa và Cách sử dụng

Mô-đun Bộ hẹn giờ cung cấp một cách thức các chức năng lập lịch để được gọi sau này tại một thời điểm nhất định.

Đối tượng Timer là một đối tượng toàn cục trong Node.js và không cần thiết phải nhập nó bằng requiretừ khóa.


Phương pháp hẹn giờ

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.

❮ Mô-đun tích hợp