Skip to main content

Reactive counter

A complete reactive app in ten lines: layout, state, events, and an energy readout.

Open in the playground (full editor) →

Walkthrough

  • app Counter: declares a reactive application — state, view, and behavior in one block.
  • signal(0) creates a reactive value. Reading it inside the view registers a dependency automatically.
  • The view is a declarative tree: elements by name (column, row, text, button), styled by properties (gap, padding, size), composed by indentation.
  • on:click -> count.update(n -> n + 1) wires an event straight to a state update. Only the text node that reads count re-renders.
  • energy.total() — the app reads its own meter and shows it in the UI.