Examples · Basics

Derived state

computed() for values, effect() for the outside world, show() for a branch.

Temperature converter from 7GUIs: two inputs stay in sync through one signal. Derived values are computed, side effects (here the document title) live in an effect, and a conditional branch is a show() with its own scope.

Playground

What to notice

  • Both inputs write the same celsius signal; fahrenheit is a computed, never stored twice.
  • effect() re-runs only when a signal it read changes; it is disposed with the component.
  • show() creates and destroys the warning branch instead of toggling a class, so nothing leaks.

Type 100 in either field and watch the title of the frame and the warning appear.