本文整理汇总了TypeScript中react-redux.Dispatch类的典型用法代码示例。如果您正苦于以下问题:TypeScript Dispatch类的具体用法?TypeScript Dispatch怎么用?TypeScript Dispatch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Dispatch类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: return
return (dispatch: Dispatch<AdminUIState>) => {
dispatch(instructionsBoxCollapsedSetting.set(collapsed));
dispatch(saveUIData({
key: INSTRUCTIONS_BOX_COLLAPSED_KEY,
value: collapsed,
}));
};
示例2: viewportToTile
(dispatch : Dispatch<Action>) => {
const [tx, ty] = viewportToTile(x, y);
if(tx < 0 || ty < 0 || tx > 128 || ty > 128){
dispatch(zoomOutOf());
}else{
dispatch(zoomInto(tx, ty));
}
};
示例3: async
return async (dispatch: Dispatch<any>) => {
dispatch(beginSaveRecipe());
try {
const savedRecipe = await save(recipe);
dispatch(saveRecipeSuccess(savedRecipe));
} catch (e) {
dispatch(saveRecipeError(recipe));
}
};
示例4: return
return (dispatch: Dispatch<State>, getState: () => State) => {
dispatch(ActionCreators.GuestAuthStarted.create({}));
fetch(`${config.apiUrl}TODO`, {
method: 'POST',
body: JSON.stringify({token: loginToken}),
headers: {
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json'
},
})
.then(res => res.json())
.then(data => {
if (data.userId) {
dispatch(ActionCreators.GuestAuthSuccess.create({apiToken: data.userId, playlistId: data.playlistId }));
} else {
dispatch(ActionCreators.GuestAuthError.create({
errorMessage: 'Authorization error'
}));
}
})
.catch((error: Error) => {
dispatch(ActionCreators.GuestAuthError.create({
errorMessage: error.message ? error.message : 'Authorization error'
}));
});
};
示例5: return
return (dispatch: Dispatch<State>, getState: () => State) => {
dispatch(ActionCreators.PlaylistFetchStarted.create({}));
fetch(`${config.apiUrl}playlist/tracks/${getState().user.playlistId}/${getState().user.apiToken}`)
.then(res => res.json())
.then(data => {
dispatch(ActionCreators.PlaylistFetchSuccess.create({playlist: data}));
})
.catch((error: Error) => {
dispatch(ActionCreators.PlaylistFetchError.create({
errorMessage: error.message ? error.message : 'Error'
}));
});
};
示例6: return
return (dispatch: Dispatch<State>, getState: () => State) => {
dispatch(ActionCreators.SearchFetchStarted.create({query}));
fetch(`${config.apiUrl}search/${getState().user.playlistId}?value=${query}`)
.then(res => res.json())
.then(data => {
dispatch(ActionCreators.SearchFetchSuccess.create({results: data}));
})
.catch((error: Error) => {
dispatch(ActionCreators.SearchFetchError.create({
errorMessage: error.message ? error.message : 'Error'
}));
});
};
示例7: getEditionsForVersion
editionsPerVersion => {
const editions = getEditionsForVersion(editionsPerVersion, version);
if (editions) {
dispatch(setEditions(editions));
} else {
dispatch(setEditions(getEditionsForLastVersion(editionsPerVersion), true));
}
},
示例8: dispatch
.then(data => {
if (data.userId) {
dispatch(ActionCreators.GuestAuthSuccess.create({apiToken: data.userId, playlistId: data.playlistId }));
} else {
dispatch(ActionCreators.GuestAuthError.create({
errorMessage: 'Authorization error'
}));
}
})
示例9: Error
}, () => {
// Unsuccessful, clear all tokens
dispatch(expire());
// Close chat and close all other signalr connections
dispatch(close());
EventService.getInstance().fire("signalr.stop");
// Navigate to login
dispatch(push("/login"));
throw new Error(__("Your session expired. Please login again."));
});