本文整理匯總了TypeScript中redux.Dispatch.default方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Dispatch.default方法的具體用法?TypeScript Dispatch.default怎麽用?TypeScript Dispatch.default使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類redux.Dispatch
的用法示例。
在下文中一共展示了Dispatch.default方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: async
export const flushTailBuffer = () => async (
dispatch: Dispatch<SetTableBackwardDataAction | SetTableForwardDataAction>,
getState: GetState
) => {
const {
logs: {
tableInfiniteData: {
forward: currentTailBuffer,
backward: currentBackward,
},
},
} = getState()
const combinedBackward = combineTableData(currentTailBuffer, currentBackward)
await dispatch(setTableBackwardData(combinedBackward))
await dispatch(setTableForwardData(defaultTableData))
}
示例2: fetch
export const fetchUsers = () => async (
dispatch: Dispatch<StoreState>,
getState: () => StoreState
) => {
if (Object.keys(getState().users._cache).length > 0) return
dispatch(setLoading(true))
dispatch(
cacheUsers(
await fetch('http://jsonplaceholder.typicode.com/users').then(response =>
response.json()
)
)
)
dispatch(setLoading(false))
}
示例3: getDefinitions
return getDefinitions(component).then(definitions => {
const filtered = definitions
.filter(definition => definition.type !== 'LICENSE')
// do not display this setting on project level
.filter(
definition => !component || definition.key !== 'sonar.branch.longLivedBranches.regex'
);
dispatch(receiveDefinitions(filtered));
});
示例4: async
export const addCellAsync = (dashboard: Dashboard) => async (
dispatch: Dispatch<Action>
): Promise<void> => {
const cell = getNewDashboardCell(dashboard)
try {
const createdCell = await addCellAJAX(dashboard.id, cell)
const updatedDashboard = {
...dashboard,
cells: [...dashboard.cells, createdCell],
}
dispatch(loadDashboard(updatedDashboard))
dispatch(notify(copy.cellAdded()))
} catch (error) {
console.error(error)
}
}
示例5: next
const middleware: Middleware = (store: MiddlewareAPI<AppState>) => (next: Dispatch<AppState>) => (action: AppAction) =>
{
switch(action.type)
{
case "REQUEST_SYSTEM_APPS": fetchSystemApps(store, action as RequestSystemAppsAction); break;
}
return next(action);
};
示例6: return
return (dispatch:Dispatch<CounterAction>, getState: ()=>ICounterState) => {
const {counter} = getState();
if(counter % 2 == 0) {
return;
}
dispatch(increment);
}
示例7: async
export const prioritizeItems = (items: MainReportItem[]) => async (dispatch: Dispatch<{}>) => {
dispatch(onPrioritizeRequest());
try {
const data = await exampleClient.prioritizeItems(items);
if (data) {
dispatch(onPrioritizeSuccess(data));
}
} catch (err) {
dispatch(onPrioritizeFailure(err));
return false;
}
return true;
};
示例8: 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
}));
}
};
示例9: async
saveAccount: (data: UserClient) => async (
dispatch: Dispatch<UpdateAction>,
getState: () => StateTree
) => {
const { api } = getState();
dispatch({
type: ActionType.UPDATE,
state: { isFetchingAccount: true },
});
dispatch({
type: ActionType.UPDATE,
state: {
account: await api.saveAccount(data),
isFetchingAccount: false,
},
});
await actions.claimLocalUser(dispatch, getState);
},
示例10: dispatch
onDrop: (e: DragEvent, clientRect: ClientRect) => {
e.preventDefault();
dispatch(
Actions.addFigure(
e.dataTransfer.getData("shape"),
e.clientX - clientRect.left,
e.clientY - clientRect.top
)
);
},