當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Map.updateIn方法代碼示例

本文整理匯總了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')));
開發者ID:vire,項目名稱:hlad-ui,代碼行數:2,代碼來源:recipes.ts

示例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:
開發者ID:nteract,項目名稱:nteract,代碼行數:67,代碼來源:index.ts


注:本文中的Immutable.Map.updateIn方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。