Skip to content
F
GitHubLight theme

@flowview/dom · @flowview/reactive

Small client-side views

A compiled .flow template renders into one element. Your application owns the state and decides when to update. FlowView does not make templates reactive on its own.

Live example

Standalone .flow + Events + signal

@flowview/dom

createView(target, render) binds a render function to an element.render() and update() both replace the target's HTML with a fresh render. There is no virtual DOM and no diffing.

Because Events uses delegated listeners, handlers keep working after every replacement. No rebinding code is needed.

ts
import { createView } from "@flowview/dom";
import { render } from "./items.flow";

const view = createView("#app", render);

view.render({ items: [] });

const summary = view.ref<HTMLParagraphElement>("summary");
const items = view.refs<HTMLLIElement>("item");
view.update({ items: [{ id: 1, name: "Ship it" }] });
const currentItems = view.refs<HTMLLIElement>("item");
// Earlier Element handles may now be detached.

@flowview/reactive

An independent, dependency-free signal library: signal(), computed(),effect() and untracked(). It works without FlowView templates.

Use view.bind(source) to render a signal or computed value immediately and update on each synchronous change. The returned stop function detaches that source; manualrender() and update() remain available.

Standalonets
import { signal, computed, effect, untracked } from "@flowview/reactive";

const count = signal(1);
const double = computed(() => count() * 2);

effect(() => console.log(double())); // logs 2
count.set(2);                        // logs 4

// Read without subscribing the running effect or computed.
const snapshot = untracked(() => count());
With a viewts
import { createView } from "@flowview/dom";
import { signal } from "@flowview/reactive";
import { render } from "./items.flow";

const state = signal({ loading: false, items: [] });
const view = createView("#app", render);

// Initial value renders immediately; later writes replace the view.
const stop = view.bind(state);

const list = view.ref<HTMLUListElement>("list");
const rows = view.refs<HTMLLIElement>("item");

// Stop only disconnects the source. Manual updates remain available.
stop();