本文整理匯總了TypeScript中@webapp/app.service函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript service函數的具體用法?TypeScript service怎麽用?TypeScript service使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了service函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: async
return async (dispatch) => {
dispatch({
type: ConfigActionTypes.START_FETCH,
payload: null,
});
try {
const config = await app.service('configuration').get('config');
dispatch({
type: ConfigActionTypes.FETCHED,
payload: { config },
});
} catch (error) {
dispatch(
createNotification(
NotificationType.ERROR,
`Error while fetching config: ${error.message}`,
5 * 1000,
),
);
dispatch({
type: ConfigActionTypes.FETCH_ERROR,
payload: { error },
});
}
};
示例2: fetchPickup
import {
AsyncAction,
AsyncStatus,
} from '@webapp/store';
import app from '@webapp/app';
import { PickupActionTypes } from '@webapp/store/pickups/types';
import { makeGetPickupStatusById } from '@webapp/store/pickups/selectors';
import { fetchPickupPlayers } from '@webapp/store/players/actions';
const pickups = app.service('pickups');
const getPickupStatusById = makeGetPickupStatusById();
function fetchPickup(pickupId: number): AsyncAction {
return async (dispatch, getState) => {
const state = getState();
const status = getPickupStatusById(state, pickupId);
if (status !== AsyncStatus.NOT_STARTED) {
return;
}
dispatch({
type: PickupActionTypes.START_FETCH,
payload: { pickupId },
});
try {
const pickup = await pickups.get(pickupId);
dispatch({
type: PickupActionTypes.FETCHED,