本文整理汇总了TypeScript中map-like.MapLike.get方法的典型用法代码示例。如果您正苦于以下问题:TypeScript MapLike.get方法的具体用法?TypeScript MapLike.get怎么用?TypeScript MapLike.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类map-like.MapLike
的用法示例。
在下文中一共展示了MapLike.get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: LogChunk
const onWillNptExecuteEachUseCase = (payload: WillNotExecutedPayload, meta: DispatcherPayloadMeta) => {
const useCase = meta.useCase;
if (!useCase) {
return;
}
const parentUseCase =
meta.parentUseCase !== useCase && meta.parentUseCase instanceof UseCase ? meta.parentUseCase : null;
const parentSuffix = parentUseCase ? ` <- ${parentUseCase.name}` : "";
const useCaseName = useCase ? useCase.name : "<no-name>";
const title = `${useCaseName}${parentSuffix}`;
const args = payload.args.length && payload.args.length > 0 ? payload.args : [undefined];
const log = [`${useCaseName} not execute:`].concat(args);
const useCases = this.useCaseLogGroupMap.keys();
const existWorkingUseCase = useCases.length !== 0;
if (existWorkingUseCase) {
const logGroup = this.useCaseLogGroupMap.get(useCase);
if (!logGroup) {
return;
}
logGroup.addChunk(
new LogChunk({
log: [log],
payload,
useCase: meta.useCase,
timeStamp: meta.timeStamp
})
);
} else {
// immediately dump log
const logGroup = new LogGroup({ title, useCaseName: useCaseName });
this.printLogger.printLogGroup(logGroup);
}
};
示例2:
const getTransactionLogGroup = (meta: DispatcherPayloadMeta) => {
// if it is transaction, add this logGroup as child of transaction
const transactionId = meta.transaction && meta.transaction.id;
if (transactionId) {
return this._transactionMap.get(transactionId);
}
return;
};
示例3: tryGetState
const onChangeStore = (payload: StoreChangedPayload, meta: DispatcherPayloadMeta) => {
const store = payload.store as Store;
const storeName = store.name ? store.name : "no-name";
// one, or more stores
const useCases = this.useCaseLogGroupMap.keys();
const workingUseCaseNames = useCases.map(useCase => {
return useCase.name;
});
const existWorkingUseCase = workingUseCaseNames.length !== 0;
if (existWorkingUseCase) {
const state = tryGetState(store);
if (meta.useCase) {
const logGroup = this.useCaseLogGroupMap.get(meta.useCase);
if (!logGroup) {
return;
}
logGroup.addChunk(
new LogChunk({
log: [`\u{1F4BE} Store:${storeName}`, state !== null ? state : store],
payload,
useCase: meta.useCase,
timeStamp: meta.timeStamp
})
);
} else {
// add log to all UseCase
this.addLog([`\u{1F4BE} Store:${storeName}`, state !== null ? state : store]);
if (workingUseCaseNames.length >= 2) {
this.addLog(`\u{2139}\u{FE0F} Currently executing UseCases: ${workingUseCaseNames.join(", ")}`);
}
}
} else {
// Async update of StoreGroup
const transactionLogGroup = getTransactionLogGroup(meta);
if (transactionLogGroup) {
const state = tryGetState(store);
transactionLogGroup.addChunk(
new LogChunk({
log: [`\u{1F4BE} Store:${storeName}`, state !== null ? state : store],
timeStamp: meta.timeStamp
})
);
} else {
// If isolated store update, immediate dump this
const storeLogGroup = new LogGroup({
title: `Store(${storeName}) is changed`
});
const state = tryGetState(store);
storeLogGroup.addChunk(
new LogChunk({
log: [`\u{1F4BE} Store:${storeName}`, state !== null ? state : store],
timeStamp: meta.timeStamp
})
);
this.printLogger.printLogGroup(storeLogGroup);
}
}
};
示例4: close
/**
* End transaction of the useCaseExecutor/UseCase
*/
close(useCaseExecutor: UseCaseExecutor<any>) {
const unsubscribe = this.unsubscribeMap.get(useCaseExecutor);
if (typeof unsubscribe !== "function") {
console.error(
"Warning(UnitOfWork): This UseCaseExecutor is not opened or already closed.",
useCaseExecutor
);
return;
}
unsubscribe();
this.unsubscribeMap.delete(useCaseExecutor);
}
示例5: deepEqual
this.ruleNames.forEach(ruleName => {
const rule = this.rules[ruleName];
const ruleConfig = this.rulesConfig[ruleName];
const savedConfigList = addedRuleMap.get(rule) || [];
// same ruleCreator and ruleConfig
const hasSameConfig = savedConfigList.some(savedConfig => {
return deepEqual(savedConfig, ruleConfig, { strict: true });
});
if (hasSameConfig) {
return;
}
newRawRules[ruleName] = rule;
newRawRulesConfig[ruleName] = ruleConfig;
// saved
savedConfigList.push(ruleConfig);
addedRuleMap.set(rule, savedConfigList);
});