Skip to content

@mega-yfue/eufy-sdk / Timer

Class: Timer

A restartable single-shot timer — the arm / cancel / re-arm pattern the P2P lifecycle repeats in several places (session idle-detach, stream linger, battery budget + its grace, the warm-up deadline). arm (re)schedules, replacing any pending fire; cancel clears it; the handle clears itself right before firing so pending reads false inside the callback. The timer is unref'd so a pending fire never keeps the process alive.

Constructors

Constructor

ts
new Timer(): Timer;

Returns

Timer

Accessors

pending

Get Signature

ts
get pending(): boolean;

Whether a fire is currently scheduled.

Returns

boolean

Methods

arm()

ts
arm(ms, fn): void;

(Re)arm to run fn after ms, cancelling any already-pending fire.

Parameters

ms

number

fn

() => void

Returns

void


cancel()

ts
cancel(): void;

Cancel a pending fire. No-op if not armed.

Returns

void

Independent and unofficial. Not affiliated with, endorsed by, or sponsored by Anker Innovations, Anker eufy, or eufy. "Anker eufy", "eufy" and "Anker" are trademarks of their respective owners. Use responsibly — rapid or failed logins can trigger captcha or temporary cooldowns.