Bundle / foldkit-bundle
Extending a bundle
Bundles are pipeable. Each combinator returns a new bundle and leaves the original unchanged, and its callbacks are typed from the bundle:
ts
const LoggedCounter = Counter.pipe(
Bundle.rename('LoggedCounter'),
Bundle.mapUpdate(update => (model, message, args) => {
console.log(message._tag)
return update(model, message, args)
}),
Bundle.withHelpers({ clear: (model: CounterModel) => ({ model: { ...model, count: 0 } }) }),
)mapInit, mapView, withView, and withSubscriptions complete the set.
mapUpdate layers run outer then inner. mapView wraps the view a bundle has,
keeping its inputs; withView gives a bundle a view with inputs of that view's
own, which is how a package that only draws (such as foldkit-mixins-form)
adds a view to a bundle it did not write.