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