当前位置: 首页>>代码示例>>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;未经允许,请勿转载。