Registry / storage / rest-redux

rest-redux

JSON →
library0.4.1jsnpmunverified

rest-redux (v0.4.1) provides Redux actions, reducers, and selectors for communicating with REST API backends, reducing boilerplate. It requires redux and redux-thunk as peer dependencies. The library is under active development and offers normalized state management, support for paginated lists, and integration with normalizr. It is designed to work out-of-the-box with Loopback APIs. Key differentiators include automatic normalization, list management with pagination, and HOC components for React integration. However, the library is still in early stages (pre-1.0) and may have limited community adoption.

npm install rest-redux
INSTALL
IMPORT
SIG · REST-REDUX
R
rest-redux
storagejavascriptv0.4.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RestRedux
import RestRedux from 'rest-redux'
const { RestRedux } = require('rest-redux')
Default export. CommonJS require must use the default property if using Babel interop.
todo actions
const todoActions = restRedux.get('todos').actions
import { todoActions } from 'rest-redux'
Actions are obtained via instance method, not direct import.
todo selectors
const todoSelectors = restRedux.get('todos').selectors
import { todoSelectors } from 'rest-redux'
Selectors are obtained via instance method, not direct import.

Sets up rest-redux with a Redux store, creates a model for 'todos', dispatches a create action, and logs instances.

import { createStore, combineReducers, applyMiddleware } from 'redux'; import thunk from 'redux-thunk'; import RestRedux from 'rest-redux'; const restRedux = new RestRedux({ basePath: 'http://localhost:3000/api', globalOptions: { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }, models: [{ modelName: 'todos' }] }); const reducer = combineReducers({ rest: restRedux.reducer }); const store = createStore(reducer, applyMiddleware(thunk, restRedux.middleware)); const todo = restRedux.get('todos'); store.dispatch(todo.actions.create({ text: 'New todo' })); console.log(todo.selectors.getInstances(store.getState()));
Debug
Known issues
gotcharedux-thunk middleware must be placed before restRedux.middleware in the middleware chain
fix
Ensure thunk is first in middleware array: applyMiddleware(thunk, restRedux.middleware)
affects: >=0.1.0
gotchaAll actions are asynchronous and return promises; do not expect synchronous state updates
fix
Use .then() or async/await after dispatching actions where needed
affects: >=0.1.0
deprecatedList feature is at concept stage and may have breaking changes in future releases
fix
Check documentation before upgrading; avoid heavy reliance on list features
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: Cannot read property 'actions' of undefined
Model name not registered in the RestRedux constructor
fix
Add the model to the models array: new RestRedux({ models: [{ modelName: 'todos' }] })
Error: Actions must be plain objects. Use custom middleware for async actions.
redux-thunk middleware not applied or placed incorrectly
fix
Ensure thunk is in middleware chain and before restRedux.middleware: applyMiddleware(thunk, ...)
Uncaught TypeError: Cannot destructure property 'reducer' of 'restRedux' as it is undefined
RestRedux instance not created correctly (missing new keyword)
fix
Use: const restRedux = new RestRedux({...})
Upgrade
Version history
0.4.1latest on npm
Audit
Dependencies
reduxrequiredCore peer dependency for Redux store integration
redux-thunkrequiredRequired middleware for async actions; must be placed before restRedux in middleware chain
Agent activity
29 hits · last 30 days
node
24
Amazon
1
Resources
rest-redux — npm install rest-redux · libregistry