本文整理汇总了TypeScript中Immutable.Map.merge方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Map.merge方法的具体用法?TypeScript Map.merge怎么用?TypeScript Map.merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Immutable.Map
的用法示例。
在下文中一共展示了Map.merge方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: appdb
export default function appdb(state:Map<string, any> = Map<string, any>({}), action:any):Map<string, any> {
switch (action.type) {
case StationsAction.RECEIVE_TOTAL_STATIONS:
return state.merge({
totalStations: {time: Date.now(), totalStations: action.totalStations}
});
case AppdbAction.AUTH_FAIL:
case AppdbAction.AUTH_PASS:
return state.merge({
credentials: {
authenticated: action.authenticated,
user: action.user,
pass: action.pass,
remember: action.remember,
reason: action.reason
},
appBaseUrlUser: `${baseUrl}?resellerUserName=${action.user}&resellerPassword=${action.pass}`
});
case AppdbAction.APP_INIT:
return state.merge({
appStartTime: Date.now(),
appBaseUrl: `${baseUrl}`
});
case AppdbAction.CLOUD_SERVERS:
return state.merge({
cloudServers: action.payload
});
case AppdbAction.SERVERS_STATUS:
return state.merge({serversStatus: action.payload});
default:
return state;
}
}
示例2: applyAction
function applyAction(state:Map<string,string>, action:IAction):Map<string,string> {
switch (action.key) {
case Keys.ChangeName :
{
var name:string = action.payload.get('name');
state = state.merge({name});
break;
}
default:
}
return state;
}
示例3: addFile
addFile(xmileDoc: XMLDocument, isMain = false): [Project, undefined] | [undefined, Error] {
const [file, err] = Project.parseFile(xmileDoc);
if (err) {
return [undefined, err];
}
const files = this.files.push(defined(file));
// FIXME: merge the other parts of the model into the project
const models = Map(
defined(file).models.map(
(xModel): [string, Model] => {
const model = new Model(this, xModel);
return [model.ident, model];
},
),
);
let dupErr: Error | undefined;
models.forEach((model, name) => {
if (this.models.has(name)) {
dupErr = new Error(`duplicate name ${name}`);
}
});
if (dupErr) {
return [undefined, dupErr];
}
const xMod = new xmile.Variable({
type: 'module',
name: 'main',
});
const main = new Module(xMod);
let newProject = this.mergeDeep({
files,
models: this.models.merge(models),
main,
});
if (models.has('main') && defined(file).header && defined(defined(file).header).name) {
newProject = newProject.set('name', defined(defined(file).header).name);
}
return [newProject, undefined];
}
示例4: fill
/**
* Merges data provided with data contained in this.data.
*
* @param data
* @returns {Item}
*/
fill(data : ItemData) : this {
this.data = this.data.merge(data);
return this;
}
示例5: switch
//.........这里部分代码省略.........
// it just doesn't have a model
// entry.type
assumedType: entry.type,
lastSaved: entry.last_modified,
filepath: entry.path
})
];
}
)
);
const items = List<ContentRef>(dummyRecords.keys());
const sorted: List<string> = items.sort((aRef, bRef) => {
const a:
| RecordOf<DummyContentRecordProps>
| undefined = dummyRecords.get(aRef) as RecordOf<
DummyContentRecordProps
>;
const b:
| RecordOf<DummyContentRecordProps>
| undefined = dummyRecords.get(bRef) as RecordOf<
DummyContentRecordProps
>;
if (a.assumedType === b.assumedType) {
return a.filepath.localeCompare(b.filepath);
}
return a.assumedType.localeCompare(b.assumedType);
});
return (
state
// Bring in all the listed records
.merge(dummyRecords)
// Set up the base directory
.set(
fetchContentFulfilledAction.payload.contentRef,
makeDirectoryContentRecord({
model: makeDirectoryModel({
type: "directory",
// The listing is all these contents in aggregate
items: sorted
}),
filepath: fetchContentFulfilledAction.payload.filepath,
lastSaved:
fetchContentFulfilledAction.payload.model.last_modified,
created: fetchContentFulfilledAction.payload.model.created,
loading: false,
saving: false,
error: null
})
)
);
}
case "notebook": {
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({