[]previous and next page

Actions with pending state

useAction(action, initialState) is the ShadowJS form of React's useActionState.

For agentsUpdated

useAction(action, initialState) is the ShadowJS form of React's useActionState. dispatch(...args) runs action(previous, ...args), where previous is the last committed state. pending is true while the latest call is running. Only the latest dispatch commits: an older result that settles after a newer dispatch is dropped, so the screen never goes back to an answer that was superseded. A failure leaves the state as it was, clears pending, and is sent to the owner's error handler, so an error boundary can show it.

cache(fn, { limit }) shares one call per request. Within one root (a server render, or the client application) the same arguments return the same result without a second call. Arguments compare with Object.is, position by position. Results are kept in a list of at most limit entries (default 100); the oldest is dropped first. A call that throws is not kept. Outside any owner nothing is scoped, so the function runs every time.