1.0.0-web734.1 • Published 7 years ago
quiqup-redux-network v1.0.0-web734.1
QuiupReduxNetwork
Package that provides middlewares that handle network actions
Network Error Middleware
Middleware that dispatches actions when some network call fails
Usage
import { createStore, applyMiddleware, compose } from 'redux'
import rootReducer from './reducers'
import { networkErrorMiddleware } from '@quiqupltd/quiqup-redux-network'
export default function configureStore(preloadedState) {
return createStore(rootReducer, preloadedState, compose(
applyMiddleware(networkErrorMiddleware),
))
}
What it does
Middleware used to handle network request errors. Dispatches action type NETWORK_ERROR or handles action and continues to the next middleware
Example
let myAction = {
payload: 'test',
type: 'getStore'
}
let next = (action) => {
return (action) => {
return action
}
}
networkErrorMiddleware(action) {
// on fail
expect(next(myAction).type).toBe('NETWORK_ERROR')
// on success
expect(next(myAction).payload).toBe('test')
}
Contributing
Getting the project ready:
git clone git@gitlab.quiqup.com:frontend/quiqup-redux-network.git
cd quiqup-redux-network
npm install
Running tests
npm run test:watch
Build bundle
npm run build:watch
Working with another project
To develop with another application, you can use npm link
to connect your project to quiqup-redux-network while developing
cd quiqup-redux-network
npm link
cd /project-using-quiqup-redux-network
npm link @quiqup/quiqup-redux-network
1.0.0-web734.1
7 years ago