defineFetch API
These docs are auto-generated from typings files (
*.d.ts
).
defineFetch
This function creates a fetch factory. See How to define a fetch to learn more
function defineFetch(params: DefineFetchParams): FetchFactory;
DefineFetchParams
the shape of the parameter object that goes into defineFetch
Name | Description | Type | Required |
---|---|---|---|
displayName | The display name should be a human readable string to help you debug. | string | yes |
make | The make function defines two things: - how your fetch factory will make fetch instances and - how your fetch instances will get their data. See How to define a fetch for more info. | (...keyArgs: KeyArgs) => MakeObject | yes |
share | If share is present, this fetch factory can have its state shared. | ShareParams | no |
conflict | This determines the conflict resolution of ReSift. When two of the same fetches are inflight, one of the fetches needs to be discard. If the conflict resolution is set to cancel , the older request will becanceled. If the conflict resolution is set to ignore , the newer requestwill be ignored in favor of the older request. The default is cancel | 'cancel' | 'ignore' | no |
staticFetchFactoryId | On creation, fetch factories keep an internal random ID. If you're trying to re-hydrate this state and would like your fetch factories to resolve to the same ID instead of a random ID, you can set this property. | string | no |
MakeObject
When defining the make
function in defineFetch
, you must return this object.
Name | Description | Type | Required |
---|---|---|---|
request | (...fetchArgs: FetchArgs) => (services: any) => any | yes |
ShareParams
Name | Description | Type | Required |
---|---|---|---|
namespace | This namespace represents the group you want this fetch factory to be in. If you are doing CRUD operations to the same resource on the back-end, then you probably want to use the same namespace. See Making state consistent for more info. | string | yes |
merge | See here for more info. | | ((previous: any, next: any) => any) | no |
FetchActionFactory
the result of calling defineFetch
is a factory that returns an action creator with meta data
type FetchFactory = (...args: KeyArgs) => FetchInstance;
typedFetchFactory
A helper used to allow you to set the type of data your fetch factory will return.
See Usage with typescript for more info.
function typedFetchFactory(): (fetchFactory: FetchFactory) => FetchFactory;