本文整理汇总了TypeScript中redux.ActionCreator.default方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ActionCreator.default方法的具体用法?TypeScript ActionCreator.default怎么用?TypeScript ActionCreator.default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类redux.ActionCreator
的用法示例。
在下文中一共展示了ActionCreator.default方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: fetchMemberByUid
async function fetchMemberByUid(dispatch: Dispatch<AppState>, uid: string) {
dispatch(requestMemberByUid(uid));
const memberDoc = await db
.collection("members")
.doc(uid)
.get();
// TODO error handling
dispatch(receiveMember(memberDoc, uid, false));
}
示例2: async
return async (dispatch: Dispatch<IAction<IFeature[]>>) => {
try {
const features: IFeature[] = await api.getFeatures(feature.scope)
if (feature.scope === FeatureScope.Web) {
dispatch(getWebFeaturesSuccess(features, feature));
} else {
dispatch(getSiteFeaturesSuccess(features, feature));
}
} catch (error) {
dispatch(handleAsyncError(constants.ERROR_MESSAGE_GETTING_FEATURES, error));
}
};
示例3: fetchMemberByMid
async function fetchMemberByMid(
dispatch: Dispatch<AppState>,
username: string
) {
dispatch(requestMemberByUsername(username));
const memberQuery = await db
.collection("members")
.where("username", "==", username)
.get();
if (memberQuery.docs.length > 1) {
alert(
`Found multiple matching member ${username}, please email bugs@raha.io`
);
}
const memberDoc = memberQuery.docs.length === 1 ? memberQuery.docs[0] : null;
dispatch(receiveMember(memberDoc, username, true));
}
示例4: async
return async (dispatch: Dispatch<IAction<ISiteContent[]>>) => {
try {
const siteContent: ISiteContent[] = await api.getLists();
if (typeof messageData !== "undefined") {
dispatch(setAllSiteContentAndMessage(siteContent, messageData));
} else {
dispatch(setAllSiteContent(siteContent));
}
} catch (error) {
// tslint:disable-next-line:no-console
console.log(error);
dispatch(setMessageData({
message: constants.ERROR_MESSAGE_GET_ALL_SITE_CONTENT,
showMessage: true,
type: MessageBarType.error
}));
}
};
示例5: addTodo
Action,
Dispatch,
bindActionCreators,
ActionCreatorsMapObject
} from 'redux'
interface AddTodoAction extends Action {
text: string
}
const addTodo: ActionCreator<AddTodoAction> = (text: string) => ({
type: 'ADD_TODO',
text
})
const addTodoAction: AddTodoAction = addTodo('test')
type AddTodoThunk = (dispatch: Dispatch) => AddTodoAction
const addTodoViaThunk: ActionCreator<AddTodoThunk> = (text: string) => (
dispatch: Dispatch
) => ({
type: 'ADD_TODO',
text
})
declare const dispatch: Dispatch
const boundAddTodo = bindActionCreators(addTodo, dispatch)
const dispatchedAddTodoAction: AddTodoAction = boundAddTodo('test')
示例6: dispatch
) => dispatch => {
if (firebaseUser) {
dispatch(fetchMemberByUidIfNeeded(firebaseUser.uid));
}
dispatch(setFirebaseUser(firebaseUser));
};