@breadhead/thunk-error
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

thunk-error

Instalation

yarn add @breadhead/thunk-error

Usage

import { applyMiddleware, combineReducers, createStore } from 'redux'
import thunk from 'redux-thunk';

import { createErrorMiddleware } from '@breadhead/thunk-error'

export const unauthorizedMiddleware = createErrorMiddleware(
  (err) => !!err && (err.status === 401 || err.status === 403), // middleware supports this error?
  () => actions.authViolateStatus(), // dispatch result of this function  on error
)

const reducer = combineReducers({
  first: firstReducer,
})

const store = createStore(
  reducer,
  initialState,
  applyMiddleware(
    unauthorizedMiddleware,
    thunk,
  ),
)

Package Sidebar

Install

npm i @breadhead/thunk-error

Weekly Downloads

0

Version

1.0.3

License

MIT

Unpacked Size

6.7 kB

Total Files

7

Last publish

Collaborators

  • igor.kamyshev
  • iwanttobealight
  • uncleseneca