• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript typescript-fsa.isType函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中typescript-fsa.isType函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isType函数的具体用法?TypeScript isType怎么用?TypeScript isType使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了isType函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1:

const reducer: Reducer<State> = (state = defaultState, action) => {
  if (isType(action, getLinodeTypesActions.started)) {
    return {
      ...state,
      loading: true
    };
  }

  if (isType(action, getLinodeTypesActions.done)) {
    const { result } = action.payload;

    return {
      ...state,
      loading: false,
      lastUpdated: Date.now(),
      entities: result,
      results: result.map(t => t.id)
    };
  }

  if (isType(action, getLinodeTypesActions.failed)) {
    const { error } = action.payload;

    return {
      ...state,
      loading: false,
      error
    };
  }

  return state;
};
开发者ID:linode,项目名称:manager,代码行数:32,代码来源:linodeType.reducer.ts


示例2: updateOrAdd

const reducer: Reducer<State> = (state = defaultState, action) => {

  if (isType(action, getImagesRequest)) {
    return {
      ...state,
      loading: true,
    };
  }

  if (isType(action, getImagesSuccess)) {
    const { payload } = action;

    return {
      ...state,
      loading: false,
      lastUpdated: Date.now(),
      entities: payload,
      results: payload.map(t => t.id)
    };
  }

  if (isType(action, getImagesFailure)) {
    const { payload } = action;

    return {
      ...state,
      loading: false,
      error: payload,
    };
  }

  if (isType(action, removeImage)) {
    const { payload } = action;
    /**
     * Events provide a numeric ID, but the actual ID is a string. So we have to respond
     * to both potentials.
     * ![Hard to work](https://media.giphy.com/media/juSraIEmIN5eg/giphy.gif)
     */
    const id = typeof payload === 'string' ? payload : `private/${payload}`
    const updated = state.entities.filter((image) => image.id !== id);

    return {
      ...state,
      entities: updated,
      results: updated.map((i) => i.id),
    };
  }

  if (isType(action, addOrUpdateImage)) {
    const { payload } = action;
    const updated = updateOrAdd(payload, state.entities);
    return {
      ...state,
      entities: updated,
      results: updated.map((i) => i.id),
    }
  }

  return state;
};
开发者ID:displague,项目名称:manager,代码行数:60,代码来源:image.reducer.ts


示例3:

const reducer: Reducer<State> = (
  state: State = defaultState,
  action: Action<Linode.Profile>
) => {
  if (isType(action, getProfileActions.started)) {
    const {} = action.payload;
    return { ...state, loading: true };
  }

  if (isType(action, getProfileActions.done)) {
    const { result } = action.payload;
    return { ...state, loading: false, lastUpdated: Date.now(), data: result };
  }

  if (isType(action, getProfileActions.failed)) {
    const { error } = action.payload;
    return { ...state, loading: false, lastUpdated: Date.now(), error };
  }

  if (isType(action, handleUpdate)) {
    return {
      ...state,
      loading: false,
      lastUpdated: Date.now(),
      data: action.payload
    };
  }

  return state;
};
开发者ID:displague,项目名称:manager,代码行数:30,代码来源:profile.reducer.ts


示例4:

const reducer: Reducer<State> = (state = defaultState, action) => {
  if (isType(action, regionsRequestActions.started)) {

    return {
      ...state,
      loading: true,
    }
  }

  if (isType(action, regionsRequestActions.done)) {
    const { result } = action.payload;

    return {
      ...state,
      loading: false,
      lastUpdated: Date.now(),
      entities: result,
      results: result.map((r) => r.id),
    }
  }

  if (isType(action, regionsRequestActions.failed)) {
    const { error } = action.payload;

    return {
      ...state,
      loading: false,
      error,
    }
  }

  return state;
};
开发者ID:displague,项目名称:manager,代码行数:33,代码来源:regions.reducer.ts


示例5: updateEvents

const reducer: Reducer<State> = (state = defaultState, action: AnyAction) => {

  if (isType(action, addEvents)) {
    const { payload: events } = action;
    const {
      events: prevEvents,
      inProgressEvents: prevInProgressEvents,
      mostRecentEventTime,
    } = state;
    const updatedEvents = updateEvents(prevEvents, events);

    return {
      ...state,
      events: updatedEvents,
      mostRecentEventTime: events.reduce(mostRecentCreated, mostRecentEventTime),
      countUnseenEvents: getNumUnseenEvents(updatedEvents),
      inProgressEvents: updateInProgressEvents(prevInProgressEvents, events),
    };
  }

  if (isType(action, updateEventsAsSeen)) {
    return {
      ...state,
      events: state.events.map((event) => ({ ...event, seen: true })),
      countUnseenEvents: 0,
    }
  }

  return state;
};
开发者ID:displague,项目名称:manager,代码行数:30,代码来源:event.reducer.ts


示例6: fbScenarioReducer

export function fbScenarioReducer(state: FBScenarioState = initialState, action: Action): FBScenarioState {
  const newState: FBScenarioState = _.cloneDeep(state);
  if (isType(action, FBScenarioActions.changeName)) {
    newState.formData.name = action.payload;
    return newState;
  }
  if (isType(action, FBScenarioActions.changeEntryPoint)) {
    newState.formData.entryPoint = action.payload;
    return newState;
  }
  if (isType(action, FBScenarioActions.requestPosts)) {
    return newState;
  }
  if (isType(action, FBScenarioActions.receivePosts)) {
    return newState;
  }
  if (isType(action, FBScenarioActions.failePosts)) {
    return newState;
  }
  if (isType(action, FBScenarioActions.cancel)) {
    return initialState;
  }
  if (isType(action, FBScenarioActions.openModal)) {
    newState.modal.isShow = true;
    newState.modal.type = action.payload;
    return newState;
  }
  if (isType(action, FBScenarioActions.closeModal)) {
    newState.modal.isShow = false;
    newState.modal.type = ModalType.NONE;
    return newState;
  }
  return newState;
}
开发者ID:kanecop,项目名称:react_laravel,代码行数:34,代码来源:FBScenario.ts


示例7: testIsType

function testIsType() {
  const withPayload = actionCreator<{foo: string}>('WITH_PAYLOAD');
  const withoutPayload = actionCreator('WITHOUT_PAYLOAD');

  if (isType(action, withPayload)) {
    const foo: string = action.payload.foo;

    // typings:expect-error
    action.payload.bar;
  }

  if (isType(action, withoutPayload)) {
    // typings:expect-error
    const foo: {} = action.payload;
  }
}
开发者ID:m0a,项目名称:typescript-fsa,代码行数:16,代码来源:index.ts


示例8:

const reducer: Reducer<State> = (state: State = defaultState, action) => {
  if (isType(action, profileRequest)) {
    return { ...state, loading: true };
  }

  if (isType(action, profileRequestSuccess)) {
    const { payload } = action;

    return { ...state, loading: false, data: payload, lastUpdated: Date.now() };
  }

  if (isType(action, profileRequestFail)) {
    const { payload } = action;

    return { ...state, loading: false, error: payload };
  }

  return state;
};
开发者ID:linode,项目名称:manager,代码行数:19,代码来源:account.reducer.ts


示例9: onStart

const reducer: Reducer<State> = (state = defaultState, action) => {
  /** Get all */
  if (isType(action, getAllNodeBalancersActions.started)) {
    return onStart(state);
  }

  if (isType(action, getAllNodeBalancersActions.done)) {
    const { result } = action.payload;

    if (result.length === 0) {
      return {
        ...state,
        loading: false,
        lastUpdated: Date.now()
      };
    }

    return onGetAllSuccess(result, state);
  }

  if (isType(action, getAllNodeBalancersActions.failed)) {
    const { error } = action.payload;
    return onError(error, state);
  }

  /** Create */

  if (isType(action, createNodeBalancersActions.done)) {
    const { result } = action.payload;

    return onCreateOrUpdate(result, state);
  }

  /** Update */
  if (isType(action, updateNodeBalancersActions.done)) {
    const { result } = action.payload;

    return onCreateOrUpdate(result, state);
  }

  /** Delete */
  if (isType(action, deleteNodeBalancerActions.done)) {
    const {
      params: { nodeBalancerId }
    } = action.payload;

    return onDeleteSuccess(nodeBalancerId, state);
  }

  /** Add */
  if (isType(action, getNodeBalancerWithConfigsActions.done)) {
    const { result } = action.payload;

    return onCreateOrUpdate(result, state);
  }

  return state;
};
开发者ID:linode,项目名称:manager,代码行数:58,代码来源:nodeBalancer.reducer.ts


示例10:

export const reducer: Reducer<State> = (state = defaultState, action) => {
  // OPEN
  if (isType(action, openBucketDrawer)) {
    return {
      ...state,
      isOpen: true
    };
  }

  // CLOSE
  if (isType(action, closeBucketDrawer)) {
    return {
      ...state,
      isOpen: false
    };
  }

  return state;
};
开发者ID:linode,项目名称:manager,代码行数:19,代码来源:bucketDrawer.reducer.ts



注:本文中的typescript-fsa.isType函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap