Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { ActionReducerMap, createSelector, MetaReducer } from "@ngrx/store";
- import { environment } from "../../environments/environment";
- import { heroReducer, HeroState } from "./hero.reducer";
- import { villainReducer, VillainState } from "./villain.reducer";
- export interface State {
- heroes: HeroState;
- villains: VillainState;
- }
- /*
- This reducers combine the two reducers which is the heroReducer and the villainReducer
- */
- export const reducers: ActionReducerMap<State> = {
- heroes: heroReducer,
- villains: villainReducer
- };
- export const metaReducers: MetaReducer<State>[] = !environment.production
- ? []
- : [];
- // selector, selecting the state.heroes
- export const selectHeroesState = (state: State) => state.heroes;
- export const selectHero = createSelector(
- selectHeroesState,
- (state: HeroState) => state.heroes
- );
- // selector, selecting the state.villains
- export const selectVillainsState = (state: State) => state.villains;
- export const selectVillain = createSelector(
- selectVillainsState,
- (state: VillainState) => state.villains
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement