本文整理匯總了TypeScript中types/redux.GetState類的典型用法代碼示例。如果您正苦於以下問題:TypeScript GetState類的具體用法?TypeScript GetState怎麽用?TypeScript GetState使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了GetState類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: return
return (dispatch: Function, getState: GetState) => {
const moduleCodes = new Set(flatMap(timetables, Object.keys));
const validateModule = getModuleCondensed(getState().moduleBank);
return Promise.all(
Array.from(moduleCodes)
.filter(validateModule)
.map((moduleCode) => dispatch(fetchModule(moduleCode))),
);
};
示例2: dispatch
dispatch(fetchModule(moduleCode)).then(() => {
const module: Module = getState().moduleBank.modules[moduleCode];
if (!module) {
dispatch(
openNotification(`Cannot load ${moduleCode}`, {
action: {
text: 'Retry',
handler: () => dispatch(addModule(semester, moduleCode)),
},
}),
);
return;
}
const lessons = getModuleTimetable(module, semester);
const moduleLessonConfig = randomModuleLessonConfig(lessons);
dispatch({
type: ADD_MODULE,
payload: {
semester,
moduleCode,
moduleLessonConfig,
},
});
});
示例3: dispatch
const onFinally = () => {
// Update the timestamp of the accessed module if it is in the store.
if (getState().moduleBank.modules[moduleCode]) {
dispatch(updateModuleTimestamp(moduleCode));
}
// Remove the LRU module if the size exceeds the maximum and if anything
// can be removed
const overLimitCount = size(getState().moduleBank.modules) - MAX_MODULE_LIMIT;
if (overLimitCount > 0) {
const { moduleBank, timetables } = getState();
const LRUModule = getLRUModules(
moduleBank.modules,
timetables.lessons,
moduleCode,
overLimitCount,
);
if (LRUModule) {
dispatch(removeLRUModule(LRUModule));
}
}
};
示例4: getState
.then(([ical, icalUtils]) => {
const {
moduleBank: { modules },
timetables,
} = getState();
const { timetable } = getSemesterTimetable(semester, timetables);
const timetableWithLessons = hydrateSemTimetableWithLessons(timetable, modules, semester);
const events = icalUtils.default(semester, timetableWithLessons, modules);
const cal = ical.default({
domain: 'nusmods.com',
prodId: '//NUSMods//NUSMods//EN',
events,
});
const blob = new Blob([cal.toString()], { type: 'text/plain' });
downloadUrl(blob, 'nusmods_calendar.ics');
})