Mirror / foldkit-mirror

One list per application with wiring

With foldkit-bundle, wiring() combines routing, startup restore, Subscriptions, and Module contracts in one assembly:

ts
import { Bundle } from 'foldkit-bundle'

const Page = Bundle.parent({ Model, Message })
const wiring = Page.assemble(Filters.wiring('UrlChanged'), Prefs.wiring())
const update = wiring.update(model => ({ model }))
const subscriptions = wiring.subscriptions()
const url = wiring.url(url => Message.UrlChanged({ url }))

Filters.wiring('UrlChanged') routes UrlChanged into Filters.urlChanged and reduces the starting URL; Prefs.wiring() routes MirrorRestored into Prefs.reduce and schedules Prefs.restore at startup. Multiple mirrors share both tags cleanly, and your own update runs after URL mirrors have updated their slices.

Slice = field refs or a writable Projection

A mirror accepts either an array of App.model field references or a Projection.pick slice:

ts
fields: [App.model.filter, App.model.page]
// or:
fields: Projection.pick(App.model.sidebar, App.model.draft)

The projection tells Mirror which fields it observes and restores without transferring ownership away from your application.