export type TimerContent = () => unknown; /** * A self-ticking directive that updates a child part on a fixed interval * without triggering a component re-render. * * The callback can return anything lit-html can render — a `TemplateResult`, * a plain string, a number, etc. * * The interval is automatically cleared when the host element is removed * from the DOM, and restarted when it reconnects. * * If `ms` changes between renders, the interval is restarted with the new * duration. * * @param callback - Function called on every tick. Return value is rendered. * @param ms - Interval in milliseconds. Required. Minimum 16ms (one frame * at 60fps) — values below this are rejected with an error * since the browser cannot paint any faster. * * @example * ```ts * import { html } from "mates"; * import { timerTemplate } from "mates"; * * // Live clock — updates every second, no component re-render * html` *
* Time: ${timerTemplate(() => new Date().toLocaleTimeString(), 1000)} *
* `; * * // Countdown * const end = Date.now() + 60_000; * html` * * ${timerTemplate(() => { * const remaining = Math.max(0, Math.ceil((end - Date.now()) / 1000)); * return remaining === 0 ? "Done!" : `${remaining}s`; * }, 1000)} * * `; * * // Dynamic HTML content * html` *
* ${timerTemplate(() => html`${new Date().toLocaleTimeString()}`, 500)} *
* `; * ``` */ export declare function timerTemplate(callback: TimerContent, ms: number): import("lit-html/directive").DirectiveResult; //# sourceMappingURL=timerDirective.d.ts.map