Site / foldkit-site
Routed pages
Site.placement states one routed page once — its link, what starts it, and
what its route arrival tells it — so the fold and the drawing never restate
the field, the wrapper, or the slot:
const PeoplePage = Site.placement(People, PeopleBundle, {
link: Link.field<Model>()('peoplePage', Link.wrapper(Message.GotPeopleMessage)),
args: parent => ({
searchText: parent.route._tag === 'People' ? parent.route.searchText : Option.none(),
}),
changed: route => People.Message.ChangedRoute({ route }),
})
const assembly = Bundle.assemble([PeoplePage.placed, Routing])
const update = assembly.update((model, message) =>
Routing.reduces(message) || message._tag === 'GotPeopleMessage' ? { model } : updateOwn(model, message),
)placed.update folds the child's Messages (route it in update through the
assembly; the wrapper tag never reaches your own branches) and placed.view
draws it. changed receives the node's own case value when its route
arrives and returns the child's Message — or nothing when the arrival needs
no answer. Pass the pages to Site.routing (pages: [PeoplePage]) and the
wiring informs each page whose route arrives, after setting the route field.
Without changed a page is never informed. Bundles with OutMessages, and
children that are not Bundles, stay on Bundle.at and Link.child directly.
With service-needing pages, name the services on both calls:
Site.routing<Model, Message, AppRoute, RemoteClient>.