Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to realize the timer of position alarm by WeChat Mini Programs

Shulou Source: shulou.com Published: 2022-06-01 04:08:08 10月03日 Update

This article mainly shows you "how WeChat Mini Programs realizes the timer of the position alarm". The content is simple and clear. I hope it can help you solve your doubts. Next, let me lead you to study and learn the article "how WeChat Mini Programs realizes the timer of the position alarm".

Demand

After setting the position of the monitoring point, we need to obtain the position of the equipment according to a certain time interval, and compare with the set monitoring point, and trigger the corresponding action if there is a qualified monitoring point. In order to achieve the above functions, we first need to achieve the function of doing something at a certain time interval-timer.

Description

Function startTimer (interval, onTimer) {

Var time = setTimeout (function () {

OnTimer ()

StartTimer (interval, onTimer)

}

Interval

)

}

The setTimeout function is called inside the function startTimer, which takes two parameters: one is the callback function (to borrow C language) that is called when Timeout occurs, and the other is the time interval, in milliseconds.

After the startTimer is executed, the system starts timing. When the specified event interval has passed, the callback function is executed: the onTimer function is first called, which is specified by the user of the startTimer. Next, the startTimer function is called again to start the next timer action. Over and over again.

It is easy to use, for example, you can use the startTimer function as follows.

OnLoad:function () {

StartTimer (1000) function () {

Console.log ("OnTimer!")

});

}

Although it is only the output of log at present, we will use this as the entrance in the next few days to achieve the function of regularly obtaining the current location and confirming the monitoring point.

The above is all the contents of the article "how to realize the timer of the position alarm by WeChat Mini Programs". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Function location timer monitor point monitor program alarm content function time article action learning help loop next two event entry again Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Huawei Shulou Technology Xiaomi Docker