@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,
  ),
)

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.3
    3
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.3
    3
  • 1.0.2
    1
  • 1.0.0
    0

Package Sidebar

Install

npm i @breadhead/thunk-error

Weekly Downloads

4

Version

1.0.3

License

MIT

Unpacked Size

6.7 kB

Total Files

7

Last publish

Collaborators

  • igor.kamyshev
  • iwanttobealight
  • uncleseneca