diff options
| author | Yorkie Liu <yorkiefixer@gmail.com> | 2018-06-01 02:26:43 +0800 |
|---|---|---|
| committer | Ryan Dahl <ry@tinyclouds.org> | 2018-05-31 23:39:44 +0200 |
| commit | 84b06879909e15f62cda430fa3f884660e0c3ec7 (patch) | |
| tree | 012cd61a91b7ee7396b2d07fa34d12dfde48ff21 | |
| parent | 38a2c042b61a448c1d4f7c0085d1eee907a0249b (diff) | |
fix all duration to delay with mdn description
| -rw-r--r-- | timers.go | 10 | ||||
| -rw-r--r-- | timers.ts | 18 |
2 files changed, 14 insertions, 14 deletions
@@ -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 } @@ -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<number, Timer>(); @@ -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) { |
