aerux
An easy way to use redux with react
Install
npm install aerux
Use
// es6// orconst createStore createModel connect actions = const store = // reducers/count.js const actions reducer = // Count.jsx Component { // ... } count: statecountCount // App.jsx const App = <Provider store=store> <Count /> </Provider>
API
createStore
create store with
redux.createStore
name | description | type | default | optional |
---|---|---|---|---|
middlewares |
redux middleware | Array |
[] |
true |
enhancers |
redux enhancer | Array |
[] |
true |
compose |
used for redux devtool | - | redux.compose |
true |
state |
initial state | any |
{} |
true |
reducers |
initial reducers | ReducersMapObject |
{} |
true |
createModel
create model with
redux-actions
const actions reducer =
name | description | type | default | optional |
---|---|---|---|---|
namespace |
namespace | string |
undefined |
false |
state |
initial state | any |
null |
true |
actions |
redux actions | ActionMap<Payload, Meta> |
true |
|
reducers |
action handlers | ReduxCompatibleReducer<State, Action<Payload>> | ReduxCompatibleReducerMeta<State, Action<Payload>, any> |
{} |
true |
Note: if you create model after create store, you can use
actions
fromaerux
directly
Notes
-
namespace
: if you presentnamespace
andstore
is created, reducer will be auto injected tostore
-
actions
:actionCreator
is created byredux-actions
-
reducers
: created byredux-actions
actions
action which created in
createModel
will be auto injected to it, you can call it directly
actions[namespace][actionName]
actionscount
connect
connect store and component like
redux.connect
, but much better
Component
Note: you can use
actions
fromaerux
directly, noconnect
actions
need, ex:
Component { actionscount } { // ... } DemoComponent
store.actions[namespace][actionName]
another alias for
actions
storeactionscount
store.injectReducer
This function is used for async inject reducer, for code-splitting
store.hotReplaceReducer
This function is used for HMR
when build application with Webpack