當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。