本文整理汇总了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;
}
}
示例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,
};
});
}
示例3: makeMultilineNotebook
export function makeMultilineNotebook(nb : Map<string, any>) {
return nb.update('cells', processCells.bind(this, breakIntoMultiline));
}
示例4: cleanMultilineNotebook
export function cleanMultilineNotebook(nb : Map<string, any>) {
return nb.update('cells', processCells.bind(this, cleanMultiline));
}
示例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));
}
示例6: addMovie
function addMovie(currentState: Map<string, List<string>>, movie: string): Map<string, List<string>> {
return currentState.update('movies', movies => movies.push(movie));
}
示例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());
}