本文整理汇总了TypeScript中actions/requests.requestAction函数的典型用法代码示例。如果您正苦于以下问题:TypeScript requestAction函数的具体用法?TypeScript requestAction怎么用?TypeScript requestAction使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了requestAction函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: fetchModuleArchive
export function fetchModuleArchive(moduleCode: ModuleCode, year: string) {
const key = fetchArchiveRequest(moduleCode, year);
const action = requestAction(key, FETCH_ARCHIVE_MODULE, {
url: NUSModsApi.moduleDetailsUrl(moduleCode, year),
});
action.meta.academicYear = year;
return action;
}
示例2: return
return (dispatch: Function, getState: GetState) => {
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));
}
}
};
const key = fetchModuleRequest(moduleCode);
return dispatch(
requestAction(key, FETCH_MODULE, {
url: NUSModsApi.moduleDetailsUrl(moduleCode),
}),
).then(
(result: any) => {
onFinally();
return result;
},
(error: any) => {
onFinally();
throw error;
},
);
};
示例3: fetchVenueList
export function fetchVenueList() {
return requestAction(FETCH_VENUE_LIST, {
url: NUSModsApi.venueListUrl(config.semester),
});
}
示例4: fetchModuleList
export function fetchModuleList() {
return requestAction(FETCH_MODULE_LIST, FETCH_MODULE_LIST, {
url: NUSModsApi.moduleListUrl(),
});
}