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


TypeScript ActionReducer.default方法代碼示例

本文整理匯總了TypeScript中@ngrx/store.ActionReducer.default方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ActionReducer.default方法的具體用法?TypeScript ActionReducer.default怎麽用?TypeScript ActionReducer.default使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@ngrx/store.ActionReducer的用法示例。


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

示例1: function

    return function (state = initialState, action : Action) {
        const { past, present, future } = state;
        switch (action.type) {

            case 'UNDO':
                const previous = past[past.length - 1];
                const newPast = past.slice(0, past.length - 1);
                return {
                    past: newPast,
                    present: previous,
                    future: [ present, ...future ]
                };
            case 'REDO':
                const next = future[0];
                const newFuture = future.slice(1);
                return {
                    past: [ ...past, present ],
                    present: next,
                    future: newFuture
                };
            default:
                // Delegate handling the action to the passed reducer
                const newPresent = reducer(present, action);
                if (present === newPresent) {
                    return state
                }
                return {
                    past: [ ...past, present ],
                    present: newPresent,
                    future: []
                }
        }
    }
開發者ID:ManuCutillas,項目名稱:ngrx-examples,代碼行數:33,代碼來源:undoable.ts

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: computeNextEntry

/**
 * Computes the next entry in the log by applying an action.
 */
function computeNextEntry(
  reducer: ActionReducer<any, any>,
  action: Action,
  state: LiftedState,
  error: any
) {
  if (error) {
    return {
      state,
      error: 'Interrupted by an error up the chain',
    };
  }

  let nextState = state;
  let nextError;
  try {
    nextState = reducer(state, action);
  } catch (err) {
    nextError = err.toString();
    console.error(err.stack || err);
  }

  return {
    state: nextState,
    error: nextError,
  };
}
開發者ID:wgerven,項目名稱:platform,代碼行數:30,代碼來源:reducer.ts


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