Learn / Wiring
Sixty seconds: two mirrors, one list
This is examples/todo-app trimmed to the wiring shape. The union carries
both mirror Messages; everything else is the application's own. (App,
Model, Message, initialModel, own, and view are the todo-app
declarations.)
ts
import { Bundle } from 'foldkit-bundle'
import { Mirror } from 'foldkit-mirror'
const Filters = Mirror.url(App, { name: 'filters', fields: [App.model.filter] })
const Prefs = Mirror.kv(App, { key: 'todo/prefs', fields: [App.model.draft] })
const Page = Bundle.parent({ Model, Message })
const wiring = Page.assemble(Filters.wiring('UrlChanged'), Prefs.wiring())
const update = wiring.update(own) // mirrors route first; own sees the rest, and UrlChanged after them
const start = wiring.initial(initialModel) // model + the restore Command
const subscriptions = wiring.subscriptions() // both mirrors' entries, merged
const url = wiring.url(next => Message.UrlChanged({ url: next }))assemble runs the startup checks now (duplicate keys, double-claimed tags,
shared resource tags) and throws naming the offenders. Nothing subscribes,
fetches, or dispatches yet: those come from the derived values. complete
then proves the runtime config was built from them:
ts
const config = wiring.complete({ update, init: () => start, subscriptions, url, view })complete returns its argument unchanged. Its work is all in the types: pass a
hand-written subscriptions and the property errors, pointing at the assembly
call that should have built it.