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

TypeScript store.ActionReducer类代码示例

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

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



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

示例1: createReducer_SetsInitialState

  @test createReducer_SetsInitialState()
  {
    type State = { num: number };
    const initialState: State = Object.freeze({ num: 1 });
    const reducer: ActionReducer<State> = createReducer({}, initialState);

    const action = { type: "sometype", num: 0 };

    assert.deepEqual(reducer(undefined, action), initialState);
  }
开发者ID:twop,项目名称:SlopFlow.Editor,代码行数:10,代码来源:structuredReducer.spec.ts


示例2: createReducer_HandlesDirectActions

  @test createReducer_HandlesDirectActions()
  {
    const handlers =
      {
        ["add"]: (state: number, payload: { num: number }): number => state + payload.num
      };

    const reducer: ActionReducer<number> = createReducer(handlers);
    const action = { type: "add", num: 1 };

    assert.equal(reducer(1, action), 2);
  }
开发者ID:twop,项目名称:SlopFlow.Editor,代码行数:12,代码来源:structuredReducer.spec.ts


示例3: addTransaction

export const transactions: ActionReducer<ITransactionStateRecord> = (state: ITransactionStateRecord, action: Action ): ITransactionStateRecord => {
    
    switch (action.type){
        case ADD_TRANSACTION:
        return addTransaction(state, action);
        
        case UPDATE_TRANSACTION:
        return updateTransaction(state, action);
        
        case DELETE_TRANSACTION:
        return deleteTransaction(state, action);
    }
    
    return state;
}
开发者ID:bryanerayner,项目名称:WorldWideBudget,代码行数:15,代码来源:transactions.reducer.ts


示例4: AppReducer

export function AppReducer(state: any, action: any) {
  if (String('<%= BUILD_TYPE %>') === 'dev') {
    return developmentReducer(state, action);
  } else {
    return productionReducer(state, action);
  }
}
开发者ID:jvassev,项目名称:xenon,代码行数:7,代码来源:index.ts


示例5: reducer

export function reducer(state: IAppState, action: Action) {
  if (environment.production) {
    return productionReducer(state, action);
  } else {
    return developmentReducer(state, action);
  }
}
开发者ID:akazimirov,项目名称:domic,代码行数:7,代码来源:index.ts


示例6: reducer

export function reducer(state: any, action: any) {
  if (String('<%= ENV %>') === 'prod') {
    return productionReducer(state, action);
  } else {
    return developmentReducer(state, action);
  }
}
开发者ID:pocmanu,项目名称:angular2-seed-advanced,代码行数:7,代码来源:web.module.ts


示例7: reducer

export function reducer(state: State, action: any) {
    const production = false;

    if (production)
        return prodReducer(state, action);
    else
        return devReducer(state, action);
}
开发者ID:qwb0920,项目名称:movieapp-ionic,代码行数:8,代码来源:index.ts


示例8: it

      it('should not turn off loading flags if you do not specify collections', () => {
        const changeSet = createTestChangeSet();
        let action: Action = new SaveEntities(changeSet, 'api/save', { correlationId: corid, isOptimistic: false });

        // Pessimistic save turns on loading flags
        let entityCache = entityCacheReducer({}, action);
        expectLoadingFlags(entityCache, true);

        action = new SaveEntitiesCancel(corid, 'Test Cancel'); // no names so no flags turned off.
        entityCache = entityCacheReducer(entityCache, action);
        expectLoadingFlags(entityCache, true);
      });
开发者ID:RajeevSingh273,项目名称:angular-ngrx-data,代码行数:12,代码来源:entity-cache-reducer.spec.ts


示例9: reducer

export function reducer(state: any, action: any) {

  const savedRecord: AppState = JSON.parse(sessionStorage.getItem('employerState'));
  let record: AppState = savedRecord !== null ? savedRecord : state; //using this, will load record from localStorage into Store//need to load state from getSavedState
  if (action.type === RESET_APP) {
    record = undefined;
  }
  if (environment.production) {
    return productionReducer(record, action);
  }
  else {
    return developmentReducer(record, action);
  }
}
开发者ID:mnitdeed,项目名称:angular2-nativescript-auth0,代码行数:14,代码来源:index.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript store.Dispatcher类代码示例发布时间:2022-05-28
下一篇:
TypeScript store.usePreMiddleware函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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