1
我創建一個反應終極版應用程序,允許用戶率和查看他們的收視率......我將有以下API方法:React Redux,如何考慮使用多種數據類型構建一個模型?
- 評級#創建(如果你發佈評級的用戶)
- 評級#指數(你在哪裏得到有關當前用戶的收視率JSON對象)
我如何創建我的減速困惑。考慮到數據模型之間的上述兩種方法都不同
我ratingReducer.js
如下所示:
import * as types from '../actions/actionTypes';
const initialState = []
export default function ratingReducer(state = initialState, action) {
//console.log('ratingReducer');
//console.log(action)
switch (action.type) {
case types.CREATE_RATING_SUCCESS:
return action.rating
case types.LOAD_YOURRATINGS_SUCCESS:
return action.your_ratings
default:
return state;
}
}
我這樣做對嗎?或者我應該有兩個單獨的減速器?
store.rating (current_user posts a rating on another user)
store.your_ratings (ratings about the current user)
一個或兩個減速器,爲什麼?謝謝