1.1.2 • Published 3 months ago

riducers v1.1.2

Weekly downloads
-
License
ISC
Repository
github
Last release
3 months ago

Dynamic Reducers for id based entities

Plug and play reducers to frontend entity based RESTful APIs.

These reducers come with insert, delete, replace, clear, and sort action types. Intercept AJAX API calls and dispatch appropriate events to maintain the entity states in redux automagically.

Usage

Initializing the reducers

import { configureStore } from '@reduxjs/toolkit'
import { reducerBuilder } from 'riducers'
import { combineReducers } from 'redux'

const reducer = {
  users: reducerBuilder('user', {stateType: 'list'}),
  auth: reducerBuilder('auth', {}),
  ui: {
    api: reducerBuilder('ui/api', { stateType: 'map'}),
  }
}

const store = configureStore({ reducer })

store.dispatch('user/insert', {payload: [{id: 1, name: 'John'}]})
store.dispatch('user/delete', {payload: [{id: 1}]})
store.dispatch('user/replace', {payload: [{id: 1, name: 'Foo'}, {id: 2, name: 'Bar'}]})
store.dispatch('user/sort', {})
store.dispatch('user/clear', {})

See the Jest tests (test/main.test.ts) for more action types and uses.

1.1.2

3 months ago

1.1.1

8 months ago

1.1.0

8 months ago

1.0.7

8 months ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago