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


TypeScript typesafe-actions.getType函數代碼示例

本文整理匯總了TypeScript中typesafe-actions.getType函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript getType函數的具體用法?TypeScript getType怎麽用?TypeScript getType使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了getType函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: watchCreateAndRemoveLastPosition

// use channel to make sure every create/remove run one by one
function* watchCreateAndRemoveLastPosition(): SagaIterator {
  try {
    const createLastPositionChan: TakeableChannel<{}> = yield actionChannel(
      getType(lastPositionsCreator.createLastPosition)
    )
    const removeLastPositionChan: TakeableChannel<{}> = yield actionChannel(
      getType(lastPositionsCreator.removeLastPosition)
    )
    while (true) {
      const [createLastPositionAction, removeLastPositionAction]: [
        ReturnType<typeof lastPositionsCreator.createLastPosition> | void,
        ReturnType<typeof lastPositionsCreator.removeLastPosition> | void
      ] = yield race([take(createLastPositionChan), take(removeLastPositionChan)])

      if (createLastPositionAction) {
        yield call(createLastPosition, createLastPositionAction)
      }

      if (removeLastPositionAction) {
        yield call(removeLastPosition, removeLastPositionAction)
      }
    }
  } catch (err) {
    console.error(err)
  }
}
開發者ID:foray1010,項目名稱:Popup-my-Bookmarks,代碼行數:27,代碼來源:saga.ts

示例2: switch

const subtitle: Middleware<{}, RootState> = store => next => action => {
  switch (action.type) {
    case getType(subtitleActions.addSubtitle):
    case getType(subtitleActions.updateSubtitle):
    case getType(subtitleActions.deleteSubtitle):
      next(action);

      const sorted = store
        .getState()
        .subtitle.data.slice(0)
        .sort((a, b) => {
          if (a.startTime > b.startTime) {
            return 1;
          } else if (a.startTime < b.startTime) {
            return -1;
          } else {
            return 0;
          }
        });
      store.dispatch(subtitleActions.sortSubtitle(sorted));

      // TODO: Update selectedIndex
      return;
    default:
      return next(action);
  }
};
開發者ID:Heeryong-Kang,項目名稱:jamak,代碼行數:27,代碼來源:subtitle.ts

示例3: switch

const handleChange: HandleFormChange<TradeState['form']> = (key) => (state = null, action) => {
  switch (action.type) {
    case getType(tradeFormChange):
      return action.payload.field === key ? action.payload.value : state
    case getType(placeTradeAction.success):
      return null
    default: return state
  }
}
開發者ID:Carl-Foster,項目名稱:exchange-app,代碼行數:9,代碼來源:trade.ts

示例4: switch

  reduxCounter: (state = 0, action) => {
    switch (action.type) {
      case getType(countersActions.increment):
        return state + 1; // action is type: { type: "INCREMENT"; }

      case getType(countersActions.add):
        return state + action.payload; // action is type: { type: "ADD"; payload: number; }

      default:
        return state;
    }
  },
開發者ID:vin1992,項目名稱:react-redux-typescript-guide,代碼行數:12,代碼來源:reducer.ts

示例5: switch

export const settings: Reducer<Settings, SettingsAction> = (
  state: Settings = initialState,
  action: SettingsAction
) => {
  switch (action.type) {
    case getType(actions.loaded):
      return {
        ...state,
        ...action.payload,
        farming: {
          ...state.farming,
          ...action.payload.farming
        }
      };

    case getType(actions.toggleCollapsedSection):
      return {
        ...state,
        collapsedSections: {
          ...state.collapsedSections,
          [action.payload]: !state.collapsedSections[action.payload]
        }
      };

    case getType(actions.setSetting):
      if (state[action.payload.property] !== action.payload.value) {
        return {
          ...state,
          [action.payload.property]: action.payload.value
        };
      } else {
        return state;
      }

    case getType(actions.setCharacterOrder):
      const order = action.payload;
      return {
        ...state,
        // Remove these characters from the list and add them, in the new sort order,
        // to the end of the list
        customCharacterSort: state.customCharacterSort
          .filter((id) => !order.includes(id))
          .concat(order)
      };

    default:
      return state;
  }
};
開發者ID:w1cked,項目名稱:DIM,代碼行數:49,代碼來源:reducer.ts

示例6: switch

const handleDepthUpdate = (direction: Direction): MyReducer<OrderType[]> => (state = [], action) => {
  switch (action.type) {
    case getType(getDepthAction.success):
      return action.payload.direction === direction ? action.payload.orders : state
    default: return state
  }
}
開發者ID:Carl-Foster,項目名稱:exchange-app,代碼行數:7,代碼來源:depth.ts

示例7: switch

const fileHandler: Middleware<{}, RootState> = store => next => action => {
  switch (action.type) {
    case getType(subtitleActions.newData):
    case getType(subtitleActions.loadData):
      store.dispatch(welcomeActions.setSubtitleReady(true));
      return next(action);
    case getType(playerActions.loadVideo):
      store.dispatch(welcomeActions.setVideoReady(true));
      return next(action);
    case getType(subtitleActions.saveData):
      const { filepath, data } = action.payload;
      ipcRenderer.send('request-save-subtitle', filepath, data);
      return next(action);
    default:
      return next(action);
  }
};
開發者ID:Heeryong-Kang,項目名稱:jamak,代碼行數:17,代碼來源:fileHandler.ts


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