我建立使用react-native
+ redux
+ immutable
当我处理API调用反应本机和终极版
我构建我的应用程序是这样
/src
-/components
-/actions (where I have action types and actions)
-/reducers
-/api (I'm not sure if I'm doing this right)
好了一个Android应用程序,所以我有一个行动,我需要做的API调用与获取这样的:
import * as types from './casesTypes'
export function getCases() {
return {
type: types.GET_CASES
}
}
这是案件减速机:
const initialState = fromJS({
isLoading: false,
cases: null
})
export default function cases(state = initialState, action = {}) {
switch(action.type) {
case types.REQUEST_CASES:
return state.set('isLoading', true)
case types.RECIVE
return state.set('cases', //set here the array that I recive from api call)
default:
return state
}
}
所以,事情是我真的不明白,我应该在哪里进行API调用,以便在缩减器中我可以合并我的初始状态与我从API调用中收回的状态?