function ExpandPanel() {
const setPanelMode = useEmit('panels.mode.set')
return (
<button onClick={() => setPanelMode({name: 'favorites', mode: 'full'})}>
Expand
</button>
)
}
function Session({request}: {request: MessageBusEmitResult<string>}) {
use(request)
return <p>Ready</p>
}
function SessionAccordion() {
const refreshToken = useEmit('auth.token.refresh')
const [request, setRequest] = useState<MessageBusEmitResult<string> | null>(null)
return (
<details
onToggle={(event) => setRequest(event.currentTarget.open ? refreshToken() : null)}
>
<summary>Session</summary>
<ErrorBoundary fallback={<p>Could not refresh</p>}>
<Suspense fallback={<p>Refreshing...</p>}>
{request && <Session request={request} />}
</Suspense>
</ErrorBoundary>
</details>
)
}
Returns a stable function that emits a dashboard event topic.
The event is sent immediately. Ignore the lazy result for fire-and-forget delivery, await it inside
useTransitionto track a reply, or read it with Reactuseto suspend. A reply that fails (NO_RESPONDER,TIMEOUT,ABORTED) rejects the result; when read withusethat reaches the nearest error boundary, so pair theSuspensewith one.