本文整理汇总了TypeScript中Immutable.Record.set方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Record.set方法的具体用法?TypeScript Record.set怎么用?TypeScript Record.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Immutable.Record
的用法示例。
在下文中一共展示了Record.set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
const forecastsSuccess = (state: Record<Weather>, action: Action): Record<Weather> => (
state.set('forecasts', action.payload.response)
);
示例2: task2
export function task2(
state: Record<TaskStateProp> = fromJS({
currentBoard: null,
boardMap: {},
trackMap: {},
cardMap: {},
boardSettingMap: {}
}),
action: any
) {
switch (action.type) {
case Actions.GET_TASK_BOARD.REQUEST:
if (action.meta && action.meta.isRefresh) {
return state;
}
return state.update('currentBoard', () => null).update('boardFetching', R.T);
case Actions.GET_TASK_BOARD.SUCCESS:
const normalizedBoard = normalize(action.payload, TaskBoard);
// TODO 同时设置board 里面的 setting
// TODO 把 card 和 track 用 board id 索引
return state
.update('boardFetching', R.F)
.update('currentBoard', () =>
fromJS(normalizedBoard.entities.TaskBoard[normalizedBoard.result])
)
.update('trackMap', () =>
fromJS(normalizedBoard.entities.TaskTrack || {}).sort((a: any, b: any) => {
return a.get('order') < b.get('order') ? -1 : 1;
})
)
.update('cardMap', () => fromJS(normalizedBoard.entities.TaskCard || {}));
case Actions.GET_TASK_BOARD.FAILURE:
return state.update('currentBoard', () => null).update('boardFetching', R.F);
case Actions.ADD_TASK_BOARD.SUCCESS:
const normalizedAddBoard = normalize(action.payload, TaskBoard);
return state.update('boardMap', boardMap =>
boardMap.merge(fromJS(normalizedAddBoard.entities.TaskBoard))
);
case Actions.GET_TASK_BOARD_SETTING.REQUEST:
return state;
case Actions.GET_TASK_BOARD_SETTING.SUCCESS:
return state.setIn(['boardSettingMap', action.meta.boardId], fromJS(action.payload));
case Actions.TASKBOARD_SETTING_UPDATE.REQUEST:
return state.updateIn(['boardSettingMap', action.meta.taskBoardId], setting => {
return setting.merge(fromJS(action.payload));
});
case Actions.CARD_MOVE_HANDLE.REQUEST:
return state.update('cardMap', cardMap => cardMap.merge(action.payload));
case Actions.GET_TASK_TRACK_CARD.SUCCESS:
const normalizedTrack = normalize(action.payload, TaskTrack);
return state
.updateIn(['trackMap'], trackMap => {
return trackMap.merge(fromJS(normalizedTrack.entities.TaskTrack));
})
.updateIn(['cardMap'], cardMap => {
return cardMap.merge(fromJS(normalizedTrack.entities.TaskCard));
});
case Actions.GET_TASK_ALL_BOARD.SUCCESS:
const normalizedAllBoard = normalize(action.payload, TaskBoards);
return state.update('boardMap', () => fromJS(normalizedAllBoard.entities.TaskBoard));
case Actions.UPDATE_TASK_BOARD.SUCCESS:
return state.update('currentBoard', board => {
if (!board) {
return null;
}
return board.merge(fromJS(R.omit(['id'], action.payload)));
});
case Actions.UPLOAD_TASK_BOARD_COVER.SUCCESS:
return state.update('currentBoard', board => {
if (!board) {
return null;
}
return board.merge(fromJS(R.omit(['id'], action.payload)));
});
case Actions.DESTORY_TASK_BOARD.SUCCESS:
return state.delete('currentBoard').deleteIn(['boardMap', String(action.meta.id)]);
case Actions.ADD_TASK_CARD.SUCCESS:
const normalizedAddedCard = normalize(action.payload, TaskCard);
return state
.update('cardMap', cardMap => {
return cardMap
? cardMap.merge(fromJS(normalizedAddedCard.entities.TaskCard))
: fromJS(normalizedAddedCard.entities.TaskCard);
})
.updateIn(['trackMap', action.meta.trackId], trackMap =>
trackMap.update(
'cards',
//.........这里部分代码省略.........