當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript app.service函數代碼示例

本文整理匯總了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 },
      });
    }
  };
開發者ID:TF2PickupNET,項目名稱:TF2Pickup,代碼行數:28,代碼來源:actions.ts

示例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,
開發者ID:TF2PickupNET,項目名稱:TF2Pickup,代碼行數:31,代碼來源:actions.ts


注:本文中的@webapp/app.service函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。