本文整理匯總了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());
}