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


TypeScript redux.Reducer類代碼示例

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


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

示例1: return

  return (state: S, action: any) => {
    if (action.type === STATE_LOADING_DONE) {
      return appReducer(action.payload, action)
    }

    return appReducer(state, action)
  }
開發者ID:jacekjagiello,項目名稱:redux-state-loader,代碼行數:7,代碼來源:redux-state-loader.ts

示例2: deepFreeze

export const reducerTester = <State>(): Given<State> => {
  let reducerUnderTest: Reducer<State, ActionOf<any>> = null;
  let resultingState: State = null;
  let initialState: State = null;

  const givenReducer = (reducer: Reducer<State, ActionOf<any>>, state: State): When<State> => {
    reducerUnderTest = reducer;
    initialState = { ...state };
    initialState = deepFreeze(initialState);

    return instance;
  };

  const whenActionIsDispatched = (action: ActionOf<any>): Then<State> => {
    resultingState = reducerUnderTest(initialState, action);

    return instance;
  };

  const thenStateShouldEqual = (state: State): Then<State> => {
    expect(state).toEqual(resultingState);

    return instance;
  };

  const instance: ReducerTester<State> = { thenStateShouldEqual, givenReducer, whenActionIsDispatched };

  return instance;
};
開發者ID:CorpGlory,項目名稱:grafana,代碼行數:29,代碼來源:reducerTester.ts

示例3: it

    it ('should handle ADDING and ADDED', () => {
      let reduc = reducer(undefined, {
        type: `${C.ADDING}`,
        meta: {className}
      })
      verifyClassRecord(reduc.get(className), 'adding');

      reduc = reducer(reduc, {
        type: `${C.ADDED}`,
        meta: {className}
      })
      verifyClassRecord(reduc.get(className));
    });
開發者ID:jasonaden,項目名稱:restore,代碼行數:13,代碼來源:resource-generic-reducer.spec.ts

示例4: it

    it ('should handle FINDING_LIST', () => {   
      let reduc = reducer(undefined, {
        type: `${C.FINDING_LIST}`,
        meta: {uri}
      })
      expect( reduc.get(uri).get('loading') ).toBeTruthy()

      reduc = reducer(reduc, {
        type: `${C.FOUND_LIST}`,
        meta: {uri}
      })
      expect( reduc.get(uri).loading ).toBeFalsy()
    });
開發者ID:jasonaden,項目名稱:restore,代碼行數:13,代碼來源:resource-generic-list-reducer.spec.ts

示例5: it

 it ('should handle FIND_CASE', () => {
   expect(
      reducer(undefined, {
        type: `${FIND}_${type}`,
        payload: {
          result: ['/cases/1'],
          items: {
            '/cases/1': {
              _links: {self: {href: '/cases/1'}}, _embedded: {entries: [{}]}
            }
          }
        }
      })
    ).toEqual(
      {
         result: ['/cases/1'],
         loadingMany: false,
         loadingOne: false,
         deleting: false,
         patching: false,
         adding: false,
         items: {
           '/cases/1': {
              _links: {self: {href: '/cases/1'}}, _embedded: {entries: [{}]}
            }
         },
         meta: {}
       }
    );
 });
開發者ID:jacobmumm,項目名稱:restore,代碼行數:30,代碼來源:resource-reducer.spec.ts

示例6: it

  it ('should handle DESTROYING_CASE', () => {
    let reduc = reducer(undefined, {
      type: `${DESTROYING}_${type}`
    })

    verifyDefault(reduc, 'deleting');
    expect( reduc.deleting ).toBeTruthy();
  });
開發者ID:jasonaden,項目名稱:restore,代碼行數:8,代碼來源:resource-reducer.spec.ts


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