本文整理汇总了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
)
);
},