lace:poll
Poll an element at an interval - call a method each tick, or just re-render. For the full guide with live demos, request batching, and start/stop patterns, see Polling.
Syntax
<div lace:poll.2s="update"></div> {# call update() every 2s #}
<div lace:poll.5s></div> {# no method = re-render only #}
<div lace:poll.500ms="tick"></div> {# milliseconds #}
<div lace:poll.5s.visible="update"></div> {# only while on-screen #}
<div lace:poll.1s.keep-alive="check"></div> {# keep running in a background tab #}
Modifiers
| Modifier | Behavior |
|---|---|
.{n}s / .{n}ms |
Interval in seconds or milliseconds. Default is 3s. |
.visible |
Only poll while the element is in the viewport. |
.keep-alive |
Keep polling while the tab is hidden (default pauses). |
.replay |
Replay every missed tick on catch-up instead of coalescing to one. |
Catch-up behavior
When a tab is backgrounded the browser throttles timers, so a poll can't keep its cadence while you're away. By default Interlace coalesces to the latest state: while the tab is hidden the poll pauses, and when you return it fires once for fresh data, then resumes its normal interval. The same applies to .visible polls scrolled off-screen.
This avoids the burst you'd otherwise see - a backlog of every missed interval replayed in quick succession the moment the tab regains focus. The queue is entirely client-side; each poll is an independent, stateless request, so there is nothing to "drain" on the server.
| Use case | Modifier | On return from background |
|---|---|---|
| Sampling current state - ticker, heartbeat, status (default) | - | One refresh to the latest value, then resume. |
| Cumulative effect - every tick must run server-side | .replay | Replays each missed tick in sequence. |
| Critical updates that must run even while hidden | .keep-alive | Never pauses (browser throttling still applies); still coalesces, so no burst. |
.keep-aliveand.replayare independent: the first decides whether a hidden tab keeps ticking, the second decides what to do with ticks that were missed. Combine them (.keep-alive.replay) only when a background poll must record every interval.