Bundle / foldkit-bundle-surface
Read a placement with Projections and Mirrors
Because a placement's state lives in the parent Model, its slice is already a ref on App.model (App.model.search, or ModelRef.focus(App.model.search).select(projection)). Sub-fields like App.model.search.query are addressable when the Model declares the slice as a Struct (such as with Link.wrapper), whereas Bundle.declare keeps the slice opaque at App.model.search.
With Struct-backed slices (search and filter), you can attach separate Mirror.url configs directly to their nested fields:
import { Mirror } from 'foldkit-mirror'
const SearchUrl = Mirror.url(App, {
name: 'search',
fields: [App.model.search.query],
keys: { query: { key: 'search.q' } },
})
const FilterUrl = Mirror.url(App, {
name: 'filter',
fields: [App.model.filter.query],
keys: { query: { key: 'filter.q' } },
})Why placements are not re-rooted Surfaces
A Surface lists parent Message constructors, and an agent adapter exposes one capability per constructor. Because every Message from a placement travels wrapped inside one parent variant (such as GotSearchMessage({ message })), a re-rooted Surface could only expose that single wrapper rather than individual child Messages. Declare a parent Surface over the placement's fields and list its wrapper variant in messages until Surface and Agent support wrapped child variants.
Limits
- A
Linkbuilt viaLink.andThenorLink.composefrom a ref-built Link attributes ownership to the application passed tocontractrather than the ref's application. - Surfaces cannot expose a placement's individual child Messages separately from its parent wrapper variant.
Next
- Build and place reusable widgets:
foldkit-bundle - Define feature Surfaces and Modules:
foldkit-surface - Compare Bundles and Surfaces: Surface and Bundle