Skip to main content

Redux exodus

npm npm

This tool used to manage the state of the application. This makes the state of the application more predictable and more powerful.

Getting Started#

npm install --save redux-exodus
# or if you are use yarn
yarn add redux-exodus

Recommended Structure#

srcโ”œโ”€โ”€ modulesโ”‚   โ”œโ”€โ”€ some-module.jsโ”‚   โ””โ”€โ”€ some1-module.jsโ”œโ”€โ”€ storeโ”‚   โ”œโ”€โ”€ store.jsโ”‚   โ””โ”€โ”€ rootreducer.jsโ””โ”€โ”€ App.js

Step 1: init#

Init your default settings (not required). See about init on API Exodus.init

index.js or App.js

import Exodus from 'redux-exodus'import store from './redux/store'
Exodus.init({  store})

NOTE store param not required to set, add it if you need persists function

Step 2: Create action and reducer#

Configure your action (its very simple)

module.js

import { createAction, createReducer } from 'redux-exodus';import { getPosts } from './api'
const defaultState = {  posts: []}
const getPostsAction = createAction({  key: 'posts',  name: 'GET_POSTS',  apiCall: getPosts,})
// Export actionsexport const actions = {  getPosts: getPostsAction}
// Init reducerexport default createReducer(actions, defaultState)

Note:

Step 3: Init Root reducer#

rootReducer.js

import { combineReducers } from 'redux';import MainReducer from './module'
const appReducer = combineReducers({  main: MainReducer});
export default appReducer;

Step 4: Init Store#

store.js

import { createStore } from 'redux';
import rootReducer from './rootReducer';
export function initStore() {  return createStore(rootReducer);}

Examples#

API#

See redux-exodus API

Changelog#

See the CHANGELOG to see what's new.

Like this project? โ˜… us on GitHub