Get Started. It's Free
or sign up with your email address
Redux by Mind Map: Redux

1. import logger from 'redux-logger'

2. dispatch Async

2.1. import thunk from redux-thunk

2.2. import axios for RESTFULL request

2.3. store.dispatch((dispatch) => {    dispatch({})    //do something async   } )

2.4. manage action dispatched by switch

3. dispatch Async using promise-redux

3.1. import promise from "redux-promise-middleware"

3.2. pass para promise() to applyMiddleware

3.3. dispatch standard object

3.3.1. dispatch({   type: "",   payload: axios.get('url api') })

3.4. recuder function action will have action as format TYPE_NAME_PENDDING  TYPE_NAME_REJECTED TYPE_NAME_FULFILLED

4. Redux React

4.1. export createStore(reducer, middleware)

4.2. create reducers

4.3. create function action to dispatch()

4.4. install react-redux

4.4.1. wrap react component with prodiver from react-redux. Provide store to provider ReactDOM.render(<provider store="store">      <Layout />  </provider>, app)

4.4.2. add decorator @connect() to Layout Component

4.4.2.1. @connect( (store) => { return {    data1: store.data1  } })

5. 2.1/ create reducer

5.1. single reducer as pure JS function(state, action) parameter: action as object has type and payload

5.1.1. change state with payload from action use rest para ...state to change only necesary field

5.2. multiple reducer

5.2.1. import combineReducers

5.2.2. create functions reducers

5.2.2.1. set state with rest para state = {...state, name: action: payload}

5.2.3. create combine Reducer const recuder = combineReducer({    fieldnameReducer: reduderFunctioName,    fieldnameReducer: reduderFunctioName, })

6. 3/ create store

6.1. createStore(reducer, {})

6.2. store.subscribe()

6.3. store.dispatch({type: "", payload: {})

6.3.1. dispatch must have 'type'

7. 1/ import createStore from redux

8. 2.2/ midleWare

8.1. import applyMIddleware from redux

8.2. add const middleware = applyMIddleware(midleware1, middleware2)

8.3. add third para to createStore(, , middleware);

8.4. create middleware function as follow (store)  => (next) => (action) => { }

8.4.1. call next(action), to dispatch to store