本文整理匯總了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: