import {state} from '@garage44/mithril' /** * A component's own reactive state (atlas's `lib/reactive.ts`): a view that * reads a field redraws when it is written — from a handler, a fetch, a timer — * with no `m.redraw()`. Typed as the plain shape, as there. */ export function local(initial: T): T { return state(initial) as unknown as T } /** One field of a `local()` object as a component `model`. */ export function bind(s: T, key: K): {value: T[K]} { return { get value() { return s[key] }, set value(next: T[K]) { s[key] = next }, } }