Storytel / react-redux-spinner

An automatic spinner for react and redux
https://storytel.github.io/react-redux-spinner/
MIT License
81 stars 13 forks source link

How to use with combineReducers #3

Closed tarim closed 7 years ago

tarim commented 7 years ago

Hi there,

I try to use your spinner on my application, and, I have more than ten reducers, and I used combineReducers. So, my question is, how we use it with multi reducers?

Thanks,

noseglid commented 7 years ago

The usage example in the README is with combineReducers.

tarim commented 7 years ago

Hi @noseglid ,

I see that, but, it is not clear. ok, you added it to your reducer list, and use combineReducers to build your reducer. after how do you dispatch it? or how do you add it it your actions?

Thanks,

for example I have a function for call api and get user details and dispatch them to redux store export function getUser() { return function(dispatch){ axios.get('/api/v1/Account/Get/User').then(response=>{ dispatch(getUserSuccess(response)); });

}

}

and action is

export function getUserSuccess(response) { return{type:types.GET_USER,payload:response}; }

and User reducer is

import * as types from '../actions/actionTypes';

const INITIAL_STATE = { all: [] };

export default function(state = INITIAL_STATE, action) { switch (action.type) { case types.GET_USER: return {...state,all:action.payload.data}; default: return state; } }