UseSubmitReturnType
import { UseSubmitReturnType } from "@hyper-fetch/react"
Preview
type UseSubmitReturnType<RequestType> = Omit<UseTrackedStateType<RequestType>, loading> & UseTrackedStateActions<RequestType> & { abort: () => void; bounce: { active: boolean; reset: () => void }; onSubmitAbort: (callback: OnErrorCallbackType<RequestType>) => void; onSubmitDownloadProgress: (callback: OnProgressCallbackType) => void; onSubmitError: (callback: OnErrorCallbackType<RequestType>) => void; onSubmitFinished: (callback: OnFinishedCallbackType<RequestType>) => void; onSubmitOfflineError: (callback: OnErrorCallbackType<RequestType>) => void; onSubmitRequestStart: (callback: OnStartCallbackType<RequestType>) => void; onSubmitResponseStart: (callback: OnStartCallbackType<RequestType>) => void; onSubmitSuccess: (callback: OnSuccessCallbackType<RequestType>) => void; onSubmitUploadProgress: (callback: OnProgressCallbackType) => void; refetch: () => void; submit: RequestSendType<RequestType>; submitting: boolean };
Structure
| Name | Type | Description |
|---|---|---|
| bounce | | Data related to current state of the bounce usage |
| submitting | | Request loading state |
| setData | | Action to set custom data. We can do it locally(inside hook state). If you need to update cache data use client.cache.update(). method. |
| setError | | Action to set custom error. We can do it locally(inside hook state). If you need to update cache data use client.cache.update() method. |
| setExtra | | Action to set custom additional data. We can do it locally(inside hook state). If you need to update cache data use client.cache.update() method. |
| setLoading | | Action to set custom loading. We can do it locally(inside hook state). If you need to update cache data use client.cache.update() method. |
| setRequestTimestamp | | Action to set custom timestamp. We can do it locally(inside hook state). If you need to update cache data use client.cache.update() method. |
| setResponseTimestamp | | Action to set custom timestamp. We can do it locally(inside hook state). If you need to update cache data use client.cache.update() method. |
| setRetries | | Action to set custom retries count. We can do it locally(inside hook state). If you need to update cache data use client.cache.update() method. |
| setStatus | | Action to set custom status. We can do it locally(inside hook state). If you need to turn on loading for all listening hooks use client.requestManager.events.emitLoading() method. |
| setSuccess | | Action to set custom success. We can do it locally(inside hook state). If you need to update cache data use client.cache.update() method. |
| abort | | Callback which allows to cancel ongoing requests from given queryKey. |
| onSubmitAbort | | Helper hook listening on aborting of requests. Abort events are not triggering onError callbacks. |
| onSubmitDownloadProgress | | Helper hook listening on download progress ETA. We can later match given requests by their id's or request instance which holds all data which is being transferred. |
| onSubmitError | | Helper hook listening on error response. |
| onSubmitFinished | | Helper hook listening on any response. |
| onSubmitOfflineError | | Helper hook listening on request going into offline awaiting for network connection to be restored. It will not trigger onError when 'offline' mode is set on request. |
| onSubmitRequestStart | | Helper hook listening on request start. |
| onSubmitResponseStart | | Helper hook listening on response start(before we receive all data from server). |
| onSubmitSuccess | | Helper hook listening on success response. |
| onSubmitUploadProgress | | Helper hook listening on upload progress ETA. We can later match given requests by their id's or request instance which holds all data which is being transferred. |
| refetch | | Refetch current request |
| submit | | Method responsible for triggering requests. It return Promise which will be resolved with the request. |