redux-hot-module
v0.0.50
Published
redux-hot-module
Downloads
14
Maintainers
Readme
redux-hot-module
under development
Installation
npm
npm i redux-hot-module
yarn
yarn add redux-hot-module
Usage
import { ReduxHotModule } from 'redux-hot-module'
// cached or mocked state that will be merged in (optional)
const preloadedState = localStorage.getItem('searchResults')
const ml = new ReduxHotModule('searchResults', preloadedState)
// param actions
ml.addParamAction('posts', [])
ml.addParamAction('selectedPost', null)
ml.addParamAction('pageNumber', 1)
ml.addParamAction('pageSize', 10)
ml.addParamAction('loading', false)
ml.addParamAction('hasNext', false)
// event actions
ml.addEventAction('loadNextEvent')
// reset action
ml.addResetAction('reset')
export const {
namespace,
reducer,
defaultState,
initialState,
withModuleProps,
mapStateToProps,
mapDispatchToProps,
types: {
SEARCH_RESULTS_POSTS,
SEARCH_RESULTS_SELECTED_POST,
SEARCH_RESULTS_PAGE_NUMBER,
SEARCH_RESULTS_PAGE_SIZE,
SEARCH_RESULTS_LOADING,
SEARCH_RESULTS_HAS_NEXT,
SEARCH_RESULTS_LOAD_NEXT_EVENT,
SEARCH_RESULTS_RESET
},
actions: {
postsAction,
selectedPostAction,
pageNumberAction,
pageSizeAction,
loadingAction,
hasNextAction,
loadNextEventAction,
resetAction
}
} = ml.create()
unpkg
Global name: ReduxHotModule
Requires 'react-redux' package with 'ReactRedux' global name
https://github.com/reduxjs/react-redux
https://cdnjs.com/libraries/react-redux
<script src="https://unpkg.com/redux-hot-module@latest/lib/bundle.umd.js"></script>