useAcknowledgeSignalsAlert
Acknowledges a Signals episode or a raw alert, selected when the hook is created.
When to use it
Omit the option for an episode; set episodes to false for a raw alert. Pass the selected alert ID to mutate.
Setup
Call it from a client-side React component below OvokProvider so it uses the client configured at that provider boundary.
Hook arguments
| Option | Type | Details |
|---|---|---|
grain | { episodes?: true } or { episodes: false } | Omit or select episodes: true to acknowledge an episode; set episodes: false for one raw alert. |
The grain defaults to episodes. Set episodes: false when the workflow targets an individual raw alert.
TypeScript signature
(grain: { episodes: false; }): OvokMutationState<string, SignalsRawAlert>
(grain?: { episodes?: true; }): OvokMutationState<string, SignalsAlert>
Mutation state
The mutation input is an alert or episode ID string. The default hook instance acknowledges an episode and resolves with a SignalsAlert; when created with { episodes: false }, it acknowledges a raw alert and resolves with a SignalsRawAlert.
| Field | Meaning |
|---|---|
data | Latest successful alert response. |
loading | Whether acknowledgement is running. |
error | Normalized Error from the latest failure. |
mutate | Acknowledges the selected ID and resolves with the matching alert type. |
reset | Clears mutation data and error state. |
Request behavior
The mutation is explicit: collect and validate the input in your UI, disable repeated submission while loading is true, handle the rejected promise, and render error near the action.
Example
Call the mutation from an event handler and show its error beside the action.
import { useAcknowledgeSignalsAlert } from '@ovok/core';
export function AcknowledgeButton({ id }: { id: string }) {
const { mutate, loading, error } = useAcknowledgeSignalsAlert();
async function acknowledge() {
try { await mutate(id); } catch { /* The hook exposes the error below. */ }
}
return <><button disabled={loading} onClick={() => void acknowledge()}>Acknowledge episode</button>
{error && <p role="alert">{error.message}</p>}</>;
}
// For a raw alert, initialize a separate component's hook with { episodes: false }.
The raw-alert overload returns a SignalsRawAlert result:
import { useAcknowledgeSignalsAlert } from '@ovok/core';
export function AcknowledgeRawAlertButton({ id }: { id: string }) {
const { mutate, loading, error } = useAcknowledgeSignalsAlert({ episodes: false });
return <>
<button disabled={loading} onClick={() => void mutate(id)}>Acknowledge raw alert</button>
{error && <p role="alert">{error.message}</p>}
</>;
}
Related
- Generated API reference for overloads and exact input and response types.
- React applications for provider setup and application patterns.
- Hook guide index for related hooks.