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