本文整理汇总了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');
})