Learn / Wiring
What it is
The interface, declared in foldkit-surface and repeated structurally in
foldkit-bundle (so the bundle core does not depend on Surface):
ts
interface Wiring<Model, Message, R = never, Claims extends string = string> {
readonly key: string // remote:Board
readonly handles: ReadonlyArray<Claims> // Message tags route folds
readonly shared?: readonly string[] | undefined // tags several wirings may handle
route?(model: Model, message: Message): Option<Update.Return<Model, Message, R>>
readonly init?: Update.Step<Model, Message, R> | undefined // runs once at startup
readonly onUrl?: ((model: Model, url: Url) => Model) | undefined
readonly subscriptions?: Subscription.Subscriptions<Model, Message, R> | undefined
readonly resources?: Record<string, ManagedResource.Entry<...>> | undefined
readonly contract?: Contract | undefined // for Module.validate
}Every field is optional except key and handles. A wiring is data plus
pure functions: it performs no I/O itself. R is the Effect services its
Commands and Subscription streams need (RemoteClient, a KeyValueStore);
the assembly threads it into the derived config's requirements.
The producers, one per integration:
| Integration | Call | Brings |
|---|---|---|
| Remote | Data.wiring(active, options?) | route into Data.reduce, entries per active Surface, contract, RemoteClient |
| URL mirror | Filters.wiring(tag) | routes the app's URL Message, onUrl, subscriptions, contract |
| Key-value mirror | Prefs.wiring() | routes its own MirrorRestored, restore as init, subscriptions, contract |
| Sync | TodoSync.wiring() | contract only |
| Agent | AppAgent.wiring() | contract only |