Examples
Plain HTML and JavaScript
Section titled “Plain HTML and JavaScript”The standalone project contains a counter, a form, a list, styles, and a conditional region. Its classic HTML page opens directly from disk. The same project also has an ESM entry point for a static HTTP server.
Measure a text update
Section titled “Measure a text update”The example records characterData changes with MutationObserver. Edit the second row to see the count for that interaction. View source opens the TypeScript module that runs the example.
One signal and its text node
Loading the example…
View source
import { list, mount, onCleanup, onMount, signal } from "min-reactive-framework";import type { Dispose } from "min-reactive-framework";import { button, div, li, output, span, ul } from "min-reactive-framework/html";import type { DemoLanguage } from "../example-language.js";
export function run(target: HTMLElement, lang: DemoLanguage): Dispose { const ru = lang === "ru"; const titles = ru ? ["HTML и JavaScript", "Заголовок", "Прямое обновление DOM"] : ["HTML and JavaScript", "Title", "Direct DOM update"]; const rows = titles.map((title, id) => ({ id, title: signal(title) })); const writes = signal(0); let revision = 0; let observer: MutationObserver;
return mount(target, () => { const labels = ul( { class: "mr-demo-rows" }, list( rows, (row) => row.id, (row) => li( { "data-row": row.value.id, class: { "mr-demo-target": row.value.id === 1 } }, () => row.value.title.value, ), ), );
onMount(() => { observer = new MutationObserver(() => {}); observer.observe(labels, { subtree: true, characterData: true }); }); onCleanup(() => observer?.disconnect());
function rename() { rows[1].title.value = titles[1] + " · " + ++revision; writes.value = observer.takeRecords().length; }
return div( labels, div( { class: "mr-demo-line mr-demo-controls" }, button( { type: "button", on: { click: rename } }, ru ? "Изменить вторую строку" : "Edit the second row", ), span( { class: "mr-demo-metric" }, output({ id: "mutation-count", "aria-live": "polite" }, writes), " ", ru ? "мутаций текста" : "text mutations", ), ), ); });}Try a specific behavior
Section titled “Try a specific behavior”| Example | What to try |
|---|---|
| Counter | Click the button and follow the value of a signal. |
| Signals | Write twice in a batch and watch the effect count. |
| Components | Open a panel that creates its children on demand. |
| Conditions | Open and close a branch and watch the lifecycle counters. |
| Lists | Edit a row input and reorder the list. |
| CSS and SVG | Toggle a class, a CSS property, and an SVG fill. |
| Forms | Submit a controlled form. |
| Async work | Close a request while it is pending, or simulate an error. |