当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Map.update方法代码示例

本文整理汇总了TypeScript中Immutable.Map.update方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Map.update方法的具体用法?TypeScript Map.update怎么用?TypeScript Map.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Immutable.Map的用法示例。


在下文中一共展示了Map.update方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: stations

export function stations(state:Map<string,any> = Map<string,any>(), action:any):Map<string, List<StationModel>> {

    function indexOfStation(businessId, stationId):any {
        return stations.findIndex((i:StationModel) => {
            return i.getKey('businessId') === businessId && i.getKey('id') == stationId;
        });
    }

    switch (action.type) {
        case StationsAction.RECEIVE_STATIONS:
            return state.update(action.source, (value) => action.stations);

        case StationsAction.RECEIVE_STATIONS_GEO:
            for (var i in action.payload) {
                var station = action.payload[i];
                var source = station.source;
                var stations:List<StationModel> = state.get(source);
                stations = stations.update(indexOfStation(station.businessId, station.id), (i_station:StationModel) => {
                    return i_station.setKey<StationModel>(StationModel, 'geoLocation', {
                        lat: station.lat,
                        lon: station.lon,
                        city: station.city,
                        country: station.country
                    })
                });
                state = state.setIn([source], stations);
            }
            return state;
        default:
            return state;
    }
}
开发者ID:Floodlight-Studios,项目名称:studioDashboard,代码行数:32,代码来源:StationsReducer.ts

示例2:

function toggle<T extends ContentInfo>(
  oldMap: Map<string, T>,
  id: string,
  key: string,
  status: boolean,
): Map<string, T> {
  return oldMap.update(id, c => {
    return {
      ...c,
      [key]: status,
    };
  });
}
开发者ID:xxr3376,项目名称:Learn-Project,代码行数:13,代码来源:data.ts

示例3: makeMultilineNotebook

export function makeMultilineNotebook(nb : Map<string, any>) {
  return nb.update('cells', processCells.bind(this, breakIntoMultiline));
}
开发者ID:jdetle,项目名称:commutable,代码行数:3,代码来源:cleaning.ts

示例4: cleanMultilineNotebook

export function cleanMultilineNotebook(nb : Map<string, any>) {
  return nb.update('cells', processCells.bind(this, cleanMultiline));
}
开发者ID:jdetle,项目名称:commutable,代码行数:3,代码来源:cleaning.ts

示例5: processCell

/**
 * Concatenate all "multi-line" strings from a cell (on disk -> in-mem format)
 * @param {Function} processor, map function applied to values
 * @param {Map} cell the cell to clean up
 * @return {Map} cell without multi-line strings
 */
function processCell(processor, cell : Map<string, any>) {
  return cell.update('source', processor)
             .update('outputs', processOutputs.bind(this, processor));
}
开发者ID:jdetle,项目名称:commutable,代码行数:10,代码来源:cleaning.ts

示例6: addMovie

 function addMovie(currentState: Map<string, List<string>>, movie: string): Map<string, List<string>> {
     return currentState.update('movies', movies => movies.push(movie));
 }
开发者ID:autechr3,项目名称:FullStackReduxTypescript,代码行数:3,代码来源:immutable_spec.ts

示例7: timestampPostMiddleware

export function timestampPostMiddleware(rootStore: RootStore, oldState: Map<string, any>, newState: Map<string, any>,
                                        path: List<string>, actionName: string, reducerType: string): Map<string, any> {
  return newState.update('updatedAt', () => Date.now());
}
开发者ID:mremolt,项目名称:icndb-ng2-webpack,代码行数:4,代码来源:middleware.ts


注:本文中的Immutable.Map.update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。