useResolveAll
useResolveAll reads a collection token: one every provider registers with multi: true. It returns an array, widest by default. Declaring a collection is on Providers & Resolution; this page is the API surface.
Signature
useResolveAll<T>(token: InjectionToken<T>, mode: ResolveAllMode = "chained"): T[]import { useResolveAll } from "@remodulo/react"
function OrderActionBar() {
const everyAction = useResolveAll(ORDER_ACTION) // chained: this module and every ancestor, nearest first
const ownActions = useResolveAll(ORDER_ACTION, "self") // only what this module registered
return (
<nav data-own={ownActions.length}>
{everyAction.map((action) => (
<button key={action.id} type="button" onClick={action.run}>
{action.label}
</button>
))}
</nav>
)
}OrderActionBar reads the same token twice at two widths: everything contributed from here upward, and only what this module declared.
Modes
The default is the widest.
| Mode | Returns |
|---|---|
"chained" (default) | Every contributing module from here upward, nearest first. |
"nearest" | The nearest contributing module's members, and nothing above it. |
"self" | This module's own registrations. An empty array rather than an error when there are none. |
Members come back in registration order within a module, and modules come back nearest first, so a child module's members precede the app's under "chained".
Single or collection, for the whole chain
A token is one or the other everywhere it appears. Calling this on a single registration throws rather than wrapping it in a one-element array, and calling useResolve on a collection throws rather than handing back the first member. Errors has both messages.
It is still a read
Like the other resolution hooks, this resolves once per (resolver, token, mode) and never re-renders on its own. A collection materializes whole: one read builds every member it lands, so lazy is a property of the collection rather than of a member.