@empathyco/x-components
Version:
Empathy X Components
116 lines (51 loc) • 2.21 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [FetchAndSaveHooks](./x-components.fetchandsavehooks.md)
## FetchAndSaveHooks interface
Options to use with the [createFetchAndSaveActions()](./x-components.createfetchandsaveactions.md) factory.
**Signature:**
```typescript
export interface FetchAndSaveHooks<Context extends XActionContext<StatusState, object, StatusMutations, object>, Request, Response>
```
## Properties
<table><thead><tr><th>
Property
</th><th>
Modifiers
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
[fetch](./x-components.fetchandsavehooks.fetch.md)
</td><td>
</td><td>
(context: Context, request: Request) => Promise<Response>
</td><td>
Retrieves and returns asynchronously some data.
</td></tr>
<tr><td>
[onCancel?](./x-components.fetchandsavehooks.oncancel.md)
</td><td>
</td><td>
() => void
</td><td>
_(Optional)_ Synchronous callback executed when the request is cancelled. This can happen mainly for two reasons: - The [FetchAndSaveActions.cancelPrevious](./x-components.fetchandsaveactions.cancelprevious.md) action is dispatched. - A new [FetchAndSaveActions.fetchAndSave](./x-components.fetchandsaveactions.fetchandsave.md) is dispatched before the previous one was resolved.
</td></tr>
<tr><td>
[onError?](./x-components.fetchandsavehooks.onerror.md)
</td><td>
</td><td>
(error: unknown) => void
</td><td>
_(Optional)_ Asynchronous callback executed when either the [FetchAndSaveHooks.fetch](./x-components.fetchandsavehooks.fetch.md) or [FetchAndSaveHooks.onSuccess](./x-components.fetchandsavehooks.onsuccess.md) methods fail.
</td></tr>
<tr><td>
[onSuccess](./x-components.fetchandsavehooks.onsuccess.md)
</td><td>
</td><td>
(context: Context, response: Response) => void
</td><td>
Asynchronous callback executed when the [FetchAndSaveHooks.fetch](./x-components.fetchandsavehooks.fetch.md) is performed successfully.
</td></tr>
</tbody></table>