Redux exodus
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-exodusRecommended Structure#
srcโโโ modulesโ โโโ some-module.jsโ โโโ some1-module.jsโโโ storeโ โโโ store.jsโ โโโ rootreducer.jsโโโ App.jsStep 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
storeparam not required to set, add it if you needpersistsfunction
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