UNPKG

@empathyco/x-components

Version:
24 lines (15 loc) 1.69 kB
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [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> ``` ## Methods | Method | Description | | --- | --- | | [fetch(context, request)](./x-components.fetchandsavehooks.fetch.md) | Retrieves and returns asynchronously some data. | | [onCancel()?](./x-components.fetchandsavehooks.oncancel.md) | _(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(error)?](./x-components.fetchandsavehooks.onerror.md) | _(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(context, response)](./x-components.fetchandsavehooks.onsuccess.md) | Asynchronous callback executed when the [FetchAndSaveHooks.fetch()](./x-components.fetchandsavehooks.fetch.md) is performed successfully. |