*timer / *time
Summary
*timer gives a writable finite-number data property time-dependent duration semantics. It does not mutate the property on an interval and does not create a Timer object. The aliases n-timer, n-timer.inc, n-timer.dec, n-time, n-time.tick, and n-time.format are equivalent.
Basic example
<serc-rod data='{"elapsed":0,"remaining":5000}'>
<span *timer="elapsed"></span>
<span *timer.dec="remaining"></span>
<span *time="remaining" *time.tick="100"></span>
</serc-rod>
*timer is the same as *timer.inc. Reads calculate base + elapsed; *timer.dec reads calculate max(0, base - elapsed). Assignment uses the ordinary property setter and rebases the timer.
Target rules
The value must be a writable data path, such as a, user.remaining, or items[index].remaining. Calls, arithmetic, conditional expressions, and other computed values are not timer targets. Duplicate declarations with the same target and mode share one record; conflicting modes are rejected.
Activation
- On ordinary elements, the timer is established when the directive is rendered.
- On action elements such as
button, actionable links/inputs, or elements with an event directive, the timer starts only after a successful click action. - Disabled or
defaultPreventedactions do not start the timer. - A later successful action rebases the existing timer.
Duration display
*time reads the property through the normal expression path and formats a duration. The default format is mm:ss.SSS. *time.format accepts mm:ss, hh:mm:ss, mm:ss.SSS, and hh:mm:ss.SSS. *time.tick refreshes only that element's text; it does not control timer precision and does not rerender the host.
Updates and compilation
Timer values are current whenever the property is read, including from JavaScript, *print, and ordinary expressions. A timer does not by itself cause *if or other structural expressions to reevaluate. The standalone and side-emitting compilers support writable member paths, including computed paths such as items[index].remaining.