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