From 84b06879909e15f62cda430fa3f884660e0c3ec7 Mon Sep 17 00:00:00 2001 From: Yorkie Liu Date: Fri, 1 Jun 2018 02:26:43 +0800 Subject: [PATCH] fix all duration to delay with mdn description --- timers.go | 10 +++++----- timers.ts | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/timers.go b/timers.go index dd262e7d9c..76b66cc630 100644 --- a/timers.go +++ b/timers.go @@ -12,7 +12,7 @@ type Timer struct { Done bool Cleared bool Interval bool - Duration int32 // In milliseconds + Delay int32 // In milliseconds } var timers = make(map[int32]*Timer) @@ -28,11 +28,11 @@ func InitTimers() { Id: id, Done: false, Interval: msg.TimerStartInterval, - Duration: msg.TimerStartDuration, + Delay: msg.TimerStartDelay, Cleared: false, } - if t.Duration < 10 { - t.Duration = 10 + if t.Delay < 10 { + t.Delay = 10 } t.StartTimer() timers[id] = t @@ -62,7 +62,7 @@ func (t *Timer) StartTimer() { go func() { defer t.Clear() for { - time.Sleep(time.Duration(t.Duration) * time.Millisecond) + time.Sleep(time.Duration(t.Delay) * time.Millisecond) if !t.Interval { t.Done = true } diff --git a/timers.ts b/timers.ts index d142ba76b1..6fa0e7a435 100644 --- a/timers.ts +++ b/timers.ts @@ -15,7 +15,7 @@ interface Timer { interval: boolean; // tslint:disable-next-line:no-any args: any[]; - duration: number; // milliseconds + delay: number; // milliseconds } const timers = new Map(); @@ -41,7 +41,7 @@ function onMessage(payload: Uint8Array) { function setTimer( cb: TimerCallback, - duration: number, + delay: number, interval: boolean, // tslint:disable-next-line:no-any args: any[] @@ -49,7 +49,7 @@ function setTimer( const timer = { id: nextTimerId++, interval, - duration, + delay, args, cb }; @@ -57,28 +57,28 @@ function setTimer( dispatch.sendMsg("timers", { command: pb.Msg.Command.TIMER_START, timerStartId: timer.id, - timerStartInterval: interval, - timerStartDuration: duration + timerStartInterval: timer.interval, + timerStartDelay: timer.delay }); return timer.id; } export function setTimeout( cb: TimerCallback, - duration: number, + delay: number, // tslint:disable-next-line:no-any ...args: any[] ): number { - return setTimer(cb, duration, false, args); + return setTimer(cb, delay, false, args); } export function setInterval( cb: TimerCallback, - repeat: number, + delay: number, // tslint:disable-next-line:no-any ...args: any[] ): number { - return setTimer(cb, repeat, true, args); + return setTimer(cb, delay, true, args); } export function clearTimer(id: number) {