当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript store.combineReducers函数代码示例

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


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

示例1: combineReducers

import * as fromRouter from '@ngrx/router-store';
import { compose } from '@ngrx/core/compose';
import { combineReducers } from '@ngrx/store';
import { createSelector } from 'reselect';

import * as fromScouts from './scouts';

export interface State {
  scouts: fromScouts.State;
  router: fromRouter.RouterState;
}

const reducers = {
  scouts: fromScouts.reducer,
  router: fromRouter.routerReducer
}

const reducer: ActionReducer<State> = combineReducers(reducers);

export function rootReducer(state: any, action: any) {
  return reducer(state, action);
}

export const getScoutsState = (state: State) => state.scouts;

export const getScoutIds = createSelector(getScoutsState, fromScouts.getIds);
export const getScoutEntities = createSelector(getScoutsState, fromScouts.getEntities);
export const getSelectedScoutId = createSelector(getScoutsState, fromScouts.getSelectedId);
export const getSelectedScout = createSelector(getScoutsState, fromScouts.getSelected);
export const getScout = (id: string) => createSelector(getScoutsState, fromScouts.getById(id));
export const getAllScouts = createSelector(getScoutsState, fromScouts.getAll);
开发者ID:srdone,项目名称:first-class-2,代码行数:31,代码来源:index.ts

示例2: bootstrap

//main entry point
import {bootstrap} from 'angular2/platform/browser';
import {provide} from 'angular2/core'
import {App} from './app';
import {createStore, combineReducers, Store} from '@ngrx/store'
import * as devtools from '@ngrx/devtools'
import {todos, visibilityFilter} from './todos';
import 'rxjs/Rx'

let enhanced = devtools.instrument()(createStore);

bootstrap(App, [
  provide(Store, {useValue: enhanced(combineReducers({todos, visibilityFilter})) })  
])
.catch(err => console.error(err));
开发者ID:justdaft,项目名称:sturdy-carnival,代码行数:15,代码来源:main.ts

示例3: combineReducers

import {articles} from './article';
import {combineReducers} from '@ngrx/store';

export * from './article';
export default combineReducers({ articles });
开发者ID:wageeh,项目名称:MeanMagazine,代码行数:5,代码来源:index.ts

示例4: beforeEach

 beforeEach(() => {
   combination = combineReducers(reducers, initialState);
 });
开发者ID:rjokelai,项目名称:platform,代码行数:3,代码来源:utils.spec.ts

示例5: switch

                return state.map((p: CcyPair) => {
                    if (p.value === action.payload.ccypair) {
                        p.favourite = action.payload.favourite;
                    }
                    return p;
                });

            default:
                return state;
        }
    };

export const values: Reducer<CcyPairValues> =
    (state: CcyPairValues = {}, action: Action): CcyPairValues => {
        switch (action.type) {

            case UNDERLYING_CCYPAIR_VALUE_UPDATE:
                return Object.assign({}, state, {
                    [action.payload.ccypair]: action.payload
                });

            default:
                return state;
        }
    };


export const underlyings: Reducer<Underlyings> = combineReducers({
    ccypairs, values
});
开发者ID:tomastrajan,项目名称:fintech-example,代码行数:30,代码来源:underlyings-reducer.ts

示例6: compose

ďťżimport { ActionReducer } from '@ngrx/store';
import { combineReducers } from '@ngrx/store';
import { storeFreeze } from 'ngrx-store-freeze';
import { compose } from "@ngrx/core";
import { environment } from './environments/environment';
import * as person from './person/person.store';
import * as location from './location/location.store';
import * as trip from './trip/trip.store';

export interface AppState {
    person: person.PersonState,
    location: location.LocationState,
    trip: trip.TripState
}

const reducers = {
    person: person.PersonReducer,
    location: location.LocationReducer,
    trip: trip.TripReducer
}

const developmentReducer: ActionReducer<AppState> = compose(storeFreeze, combineReducers)(reducers);
const productionReducer: ActionReducer<AppState> = combineReducers(reducers);

export function AppReducer(state: any, action: any) {
    if (environment.enableStoreFreeze && !environment.production)
        return developmentReducer(state, action);
    else
        return productionReducer(state, action);
}
开发者ID:rthiney,项目名称:sample-ng2-mvc,代码行数:30,代码来源:app.store.ts

示例7: compose

 * Because metareducers take a reducer function and return a new reducer,
 * we can use our compose helper to chain them together. Here we are
 * using combineReducers to make our top level reducer, and then
 * wrapping that in storeLogger. Remember that compose applies
 * the result from right to left.
 */
const reducers = {
  search: fromSearch.reducer,
  books: fromBooks.reducer,
  collection: fromCollection.reducer,
  layout: fromLayout.reducer,
  router: fromRouter.routerReducer,
};

const developmentReducer = compose(storeFreeze, combineReducers)(reducers);
const productionReducer = combineReducers(reducers);

export function reducer(state: any, action: any) {
  if (PROD) {
    return productionReducer(state, action);
  }
  else {
    return developmentReducer(state, action);
  }
}


/**
 * A selector function is a map function factory. We pass it parameters and it
 * returns a function that maps from the larger state tree into a smaller
 * piece of state. This selector simply selects the `books` state.
开发者ID:amikitevich,项目名称:example-app,代码行数:31,代码来源:index.ts

示例8: combineReducers

}

export const reducer = combineReducers({
  artifactEquation: fromArtifactEquation.reducer,
  artifactEstimator: fromArtifactEstimator.reducer,
  locusArtifactEstimator: fromLocusArtifactEstimator.reducer,
  artifactEstimatorLocusParams: fromArtifactEstimatorLocusParams.reducer,
  artifactEstimatorProject: fromArtifactEstimatorProject.reducer,
  bin: fromBin.reducer,
  locusBinSet: fromLocusBinSet.reducer,
  binEstimatorLocusParams: fromBinEstimatorLocusParams.reducer,
  binEstimatorProject: fromBinEstimatorProject.reducer,
  genotypingLocusParams: fromGenotypingLocusParams.reducer,
  genotypingProject: fromGenotypingProject.reducer,
  locusSet: fromLocusSet.reducer,
  locus: fromLocus.reducer,
  projectChannelAnnotations: fromProjectChannelAnnotations.reducer,
  projectSampleAnnotations: fromProjectSampleAnnotations.reducer,
  quantificationBiasEstimatorLocusParams: fromQuantificationBiasEstimatorLocusParams.reducer,
  quantificationBiasEstimatorProject: fromQuantificationBiasEstimatorProject.reducer,
  controlSampleAssociation: fromControlSampleAssociation.reducer,
  control: fromControl.reducer,
  genotype: fromGenotype.reducer,
  sampleLocusAnnotation: fromSampleLocusAnnotation.reducer,
  sample: fromSample.reducer,
  channel: fromChannel.reducer,
  ladder: fromLadder.reducer,
  plate: fromPlate.reducer,
  well: fromWell.reducer
});

export const models = {
开发者ID:Greenhouse-Lab,项目名称:MicroSPAT,代码行数:32,代码来源:index.ts

示例9: combineReducers

import { combineReducers } from '@ngrx/store';
import { counterReducer } from './counter-reducer';
import { curseReducer } from './curse-reducer';

export default combineReducers({
  counter: counterReducer,
  curse: curseReducer
});
开发者ID:ShivKamal,项目名称:ngCourse2,代码行数:8,代码来源:index.ts

示例10: switch

export type StudentAction =
FetchStudentFulFilledAction
& FetchStudentAction
& FetchStudentErrorAction
& CreateStudentAction
& CreateStudentFulFilledAction
& CreateStudentErrorAction
& UpdateStudentCountFulFiiledAction;

export type students = ActionReducer<Student[], StudentAction>;
export const students: students = (state = [], action) => {
    switch (action.type) {
        case FETCH_STUDENT_FULFILLED:
            return action.students;
        case CREATE_STUDENT_FULFILLED:
            return [...state, action.students];
        case UPDATE_STUDENT_COUNT_FULFILLED:
            const item = state.find(s => s.id === action.id);
            item.count++;
            state[state.findIndex(s => s.id === action.id)] = item;
            return state;
        default:
            return state;
    }
};

export const student = combineReducers<StudentState, StudentAction> ({
    students
});
开发者ID:Jeyabalan,项目名称:Angular,代码行数:29,代码来源:student.reducers.ts


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