On this pageParent-Owned Changes
Informing Blocks
A Block sometimes needs to react to a change it does not own. The URL may change, a server may push new data, or a sibling field may establish a new constraint. The parent observes that change, but the child still owns the state transition it causes.
Expose an inform* operation from the completed child Block, paired with an InformedOf* Message: informJoined selects Message.InformedOfJoin, for example. Select the Message constructor directly when its payload is the public input. Use a tuple producer when the inputs need mapping or refinement. The completed Block or registered Binding passes that Message through the child's update synchronously as part of the pure transition, so update owns the next Model and Commands. Composition derives delivery wrappers from its registered child Bindings. The parent does not declare those wrappers or construct child Messages to initiate this transition. It calls the projected binding.inform*(...) instead.
Use inform* whenever a parent-owned fact changes the child Model. The notification branch returns only { model } when it needs no Command or OutMessage; it does not echo an OutMessage to the parent. Keep pure selectors and derived view inputs as ordinary helpers because they do not change the child Model.
The example below uses routing. A People Block owns its search input, results, and recent searches. The root owns the Route. When the URL resolves to a People Route, the root calls people.informRouteChanged through its Binding.
Prerequisite
This page builds on the Blocks pattern. Read that first for the local Message, generated delivery, and Binding boundaries.
People declares its Model, Message, and early PeopleDefinition in cycle-safe files. The internal InformedOfRouteChange Message carries only typeof ApplicationRoute.People.Type, the variant Schema query for the part of the application Route that the feature understands. Commands import that early definition and the Message constructors they produce; the completed Block imports the Commands and their handler recipes.
import { Schema } from 'effect'
import { defineMessageUnion } from 'foldkit/message'
import { Person } from './informingBlocksModel'
import { ApplicationRoute } from './informingBlocksRoute'
export const Message = defineMessageUnion({
InformedOfRouteChange: { route: ApplicationRoute.People },
CompletedFetchPeople: { query: Schema.String, people: Schema.Array(Person) },
})import { Block } from 'foldkit'
import { Message } from './informingBlocksMessage'
import { Model } from './informingBlocksModel'
export const PeopleDefinition = Block.makeDefinition('People', {
Model,
Message,
})
export const PeopleComposition = PeopleDefinition.makeComposition()Update copies the route query into the input, records it in recent searches, and returns FetchPeople for the new results.
informRouteChanged selects Message.InformedOfRouteChange directly in the Block’s operations record. Completion creates the callable operation without constructing a Message. That operation takes one constructor payload object for the Message fields, with constructor defaults honored, and passes the child-local fact through update synchronously. It does not enqueue another Runtime Message. Update owns the invariant, Model transition, and FetchPeople Command. The parent calls the projected Binding operation without manufacturing a child Message.
Not an OutMessage
InformedOfRouteChange moves from parent to child through an inform* operation. An OutMessage moves a fact from child to parent.
The People Binding declares its parent Model field once; Composition derives its child delivery. If People declares OutMessages, select its parent-owned policy with withOutMessagePolicy and register that full Binding. The selected Binding keeps the same projected operations, so PeopleBinding.informRouteChanged still produces and handles the public InformedOfRouteChange operation through the same boundary. The ChangedUrl handler matches the next Route and composes the resulting connected child Step with the pure setRoute Step through Update.combineSteps. The makeUpdate Model supplies the registered graph, and the projected operation retains the Binding and child update requirements for application composition.
Multiple Blocks
When several page Blocks react to routing, match the next Route and return the informRouteChanged step for the page that owns that Route.
Cold loads
informRouteChanged handles later URL changes. The parent excerpt uses init: false because it does not show startup. On a cold load, root init must pass the People Route through the registered Binding’s initialization recipe, or the Binding can declare an argument policy from shared ChildInitContext. See Cold Loads and the Initial Route.
The Routing example contains the complete search flow. Routing and Navigation covers the parser that produces these Routes.
The same pattern works when a Subscription or Command tells the parent about a change the child must process. The cause changes, but ownership does not.