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