Home > SYS_Timer > clearTimeoutTimer
SYS_Timer.clearTimeoutTimer() method
Clear the specified timeout timer
Signature
typescript
function clearTimeoutTimer(id: string): boolean;1
Parameters
Parameter | Type | Description |
|---|---|---|
id | string | Timer ID |
Returns
boolean
Whether the timer was cleared successfully
Example
javascript
// 1. 挂一个 2 秒后才触发的定时器
let fired = false;
eda.sys_Timer.setTimeoutTimer('嘉立创示例_取消单次', 2000, () => { fired = true; });
// 2. 在触发前清除它
const cleared = eda.sys_Timer.clearTimeoutTimer('嘉立创示例_取消单次');
// 3. 对已清除的 ID 再清除一次,返回 false(定时器已不存在)
const again = eda.sys_Timer.clearTimeoutTimer('嘉立创示例_取消单次');
// 4. 等过原定触发时间,确认回调没有被触发
await new Promise(resolve => setTimeout(resolve, 1000));
console.log('清除结果:', cleared);
console.log('再次清除同一 ID:', again);
console.log('回调是否仍被触发:', fired);1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16