本文整理汇总了TypeScript中Immutable.Map.updateIn方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Map.updateIn方法的具体用法?TypeScript Map.updateIn怎么用?TypeScript Map.updateIn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Immutable.Map
的用法示例。
在下文中一共展示了Map.updateIn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
const clickedShowEdit = (state: ImmutableMap<any, any>, payload: PayloadType) => state
.updateIn(['recipes', payload], recipe => recipe.set('editing', !recipe.get('editing')));
示例2: switch
//.........这里部分代码省略.........
const immutableNotebook = fromJS(
fetchContentFulfilledAction.payload.model.content
);
return state.set(
fetchContentFulfilledAction.payload.contentRef,
makeNotebookContentRecord({
created: fetchContentFulfilledAction.payload.created,
lastSaved: fetchContentFulfilledAction.payload.lastSaved,
filepath: fetchContentFulfilledAction.payload.filepath,
model: makeDocumentRecord({
notebook: immutableNotebook,
savedNotebook: immutableNotebook,
transient: Map({
keyPathsForDisplays: Map(),
cellMap: Map()
}),
cellFocused: immutableNotebook.getIn(["cellOrder", 0])
}),
loading: false,
saving: false,
error: null
})
);
}
}
// NOTE: There are no other content types (at the moment), so we will just
// warn and return the current state
console.warn("Met some content type we don't support");
return state;
case actionTypes.CHANGE_FILENAME: {
const changeFilenameAction = action as actionTypes.ChangeFilenameAction;
return state.updateIn(
[changeFilenameAction.payload.contentRef],
contentRecord =>
contentRecord.merge({
filepath: changeFilenameAction.payload.filepath
})
);
}
case actionTypes.SAVE_FULFILLED: {
const saveFulfilledAction = action as actionTypes.SaveFulfilled;
return state
.updateIn(
[saveFulfilledAction.payload.contentRef, "model"],
(model: ContentModel) => {
// Notebook ends up needing this because we store a last
// saved version of the notebook Alternatively, we could
// be storing a hash of the content to compare 🤔
if (model && model.type === "notebook") {
return notebook(model, saveFulfilledAction);
}
return model;
}
)
.setIn(
[saveFulfilledAction.payload.contentRef, "lastSaved"],
saveFulfilledAction.payload.model.last_modified
)
.setIn([saveFulfilledAction.payload.contentRef, "loading"], false)
.setIn([saveFulfilledAction.payload.contentRef, "saving"], false)
.setIn([saveFulfilledAction.payload.contentRef, "error"], null);
}
// Defer all notebook actions to the notebook reducer
case actionTypes.SEND_EXECUTE_REQUEST: