The resource to be bound, the shape describing it and the values wanted; read as the component first renders and whenever the store, the resource identifier or the template change, so a view is expected to keep the shape stable for the lifetime of the component
Readonlyentry: stringThe identifier of the resource, either absolute or relative to the current location.
Readonlyshape: SThe shape the retrieved resource is validated against, possibly deferred to break definition cycles.
Readonlymodel: TThe template stating which values of the resource are retrieved, and nothing wider.
Templates are compared by reference: any new object, even with the same content, retrieves the resource
again. A template written inline, as in useResource({ …, model: { name: {} } }), is a new object on every
render, and retrieves the resource on every render: declare it as a constant instead, or keep it in state
if it changes at runtime.
A Relay over the state of the binding, to be matched by a view with a handler for each: blank
until the resource is first retrieved, ready with the resource and the operations writing it back to the
store, or error with the Problem that prevented either; a state is kept until the next one supersedes
it, including while the resource is retrieved again after a change, under a new identifier or on reload
RangeError If entry is invalid, or relative while the location is not hierarchical
Binds a component to a resource held by the shared store.
Retrieves the resource from the store offered by the innermost enclosing Store context and keeps the component in step with it, so that a view renders what the store holds and writes changes back without driving exchanges of its own: the resource is retrieved again whenever the store signals a change to it, whoever made it.
A missing resource, a rejected write and a failed exchange alike move the binding to its
errorstate, so that a view shows them where it shows the resource and offers to retry from there; an operation the view called also rejects with the same Problem, so that the view waiting on it can tell success from failure. A failed exchange no view called for, retrieving the resource as the component renders or after the store signals a change, is reported through the binding alone and never reaches the page: only a missing Store context or an unforeseen failure does, for an enclosing Faults context to take up.The template may be fixed or replaced at runtime, and a different one has the resource retrieved again:
A template is told apart by identity, not content: declare a fixed template once, outside the component, and hold a runtime one in state of the component's own. A template written inline at the call site is a new object on every render, and has the resource retrieved again, and the component rendered again, on every render.