@empathyco/x-components
Version:
Empathy X Components
24 lines (15 loc) • 1.85 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
| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [fetch](./x-components.fetchandsavehooks.fetch.md) | | (context: Context, request: Request) => Promise<Response> | Retrieves and returns asynchronously some data. |
| [onCancel?](./x-components.fetchandsavehooks.oncancel.md) | | () => void | _(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. |
| [onError?](./x-components.fetchandsavehooks.onerror.md) | | (error: unknown) => void | _(Optional)_ Asynchronous callback executed when either the [FetchAndSaveHooks.fetch](./x-components.fetchandsavehooks.fetch.md) or [FetchAndSaveHooks.onSuccess](./x-components.fetchandsavehooks.onsuccess.md) methods fail. |
| [onSuccess](./x-components.fetchandsavehooks.onsuccess.md) | | (context: Context, response: Response) => void | Asynchronous callback executed when the [FetchAndSaveHooks.fetch](./x-components.fetchandsavehooks.fetch.md) is performed successfully. |