当前位置: 首页>>代码示例>>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;未经允许,请勿转载。