This function accepts a list of responders and executes the first one that matches, based on action type. Inspired by reduce-reducers.

Allows you to glue responders together to run in sequence. It returns the first non-undefined response, skipping the rest of the sequence. It is called someResponders because only some of the responders may be executed. By default, responders return undefined for unknown action types. The first responder to return something other than undefined is returned. If all responders return undefined, then fetchAction will fall back to fetch.


import createFetchAction, { someResponders } from 'fetch-actions'
import fakeBlueberryResponder from './responders/fakeBlueberryResponder'
import fakeCarrotResponder from './responders/fakeCarrotResponder'
import 'fetch-everywhere'

const fetchAction = createFetchAction({
  responder: someResponders(
  // <-- add other handlers here

export fetchAction

results matching ""

    No results matching ""