ReSift

ReSift

  • Docs
  • API
  • Help
  • GitHub

›API

Introduction

  • What is ReSift?
  • Installation

Tutorial

  • ReSift Rentals

Main Concepts

  • What's a fetch?
  • How to define a fetch
  • Making state consistent
  • Making sense of statuses
  • What are data services?
  • Error handling
  • Custom hooks

Examples

  • ReSift Notes (CRUD)
  • Infinite scroll
  • Custom hooks and React Router

Guides

  • ReSift vs Apollo and Relay
  • HTTP proxies
  • Usage with TypeScript
  • Usage with Redux
  • Usage with classes

API

  • About these docs
  • useStatus
  • useError
  • useDispatch
  • useData
  • useClearFetch
  • isUnknown
  • isNormal
  • isLoading
  • isError
  • defineFetch
  • dataServiceReducer
  • createStoreKey
  • createHttpService
  • createHttpProxy
  • createDataService
  • createActionType
  • combineStatuses
  • ResiftProvider
  • Guard
  • CanceledError
  • UNKNOWN
  • NORMAL
  • LOADING
  • ERROR
Edit

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

NameDescriptionTypeRequired
displayNameThe display name should be a human readable string to help you debug.stringyes
makeThe 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) => MakeObjectyes
shareIf share is present, this fetch factory can have its state shared.ShareParamsno
conflictThis 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 be
canceled. If the conflict resolution is set to ignore, the newer request
will be ignored in favor of the older request.

The default is cancel
'cancel' | 'ignore'no
staticFetchFactoryIdOn 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.
stringno

MakeObject

When defining the make function in defineFetch, you must return this object.

NameDescriptionTypeRequired
request(...fetchArgs: FetchArgs) => (services: any) => anyyes

ShareParams

NameDescriptionTypeRequired
namespaceThis 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.
stringyes
mergeSee here for more info.| ((previous: any, next: any) => any)
| { [key: string]: (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;
← isErrordataServiceReducer →
  • defineFetch
  • DefineFetchParams
  • MakeObject
  • ShareParams
  • FetchActionFactory
  • typedFetchFactory
ReSift
Docs
What is ReSift?What's a fetch?API
Community
Ask a questionOpen an issue@ meLeave feedback
More
StarBuild StatusCoverage Status
Copyright © 2021 Sift
www.justsift.com