SHARE
TWEET

Untitled

a guest Mar 18th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { ActionReducerMap, createSelector, MetaReducer } from "@ngrx/store";
  2. import { environment } from "../../environments/environment";
  3. import { heroReducer, HeroState } from "./hero.reducer";
  4. import { villainReducer, VillainState } from "./villain.reducer";
  5.  
  6. export interface State {
  7.   heroes: HeroState;
  8.   villains: VillainState;
  9. }
  10.  
  11. /*
  12.   This reducers combine the two reducers which is the heroReducer and the villainReducer
  13. */
  14. export const reducers: ActionReducerMap<State> = {
  15.   heroes: heroReducer,
  16.   villains: villainReducer
  17. };
  18.  
  19. export const metaReducers: MetaReducer<State>[] = !environment.production
  20.   ? []
  21.   : [];
  22.  
  23. // selector, selecting the state.heroes
  24. export const selectHeroesState = (state: State) => state.heroes;
  25. export const selectHero = createSelector(
  26.   selectHeroesState,
  27.   (state: HeroState) => state.heroes
  28. );
  29.  
  30. // selector, selecting the state.villains
  31. export const selectVillainsState = (state: State) => state.villains;
  32. export const selectVillain = createSelector(
  33.   selectVillainsState,
  34.   (state: VillainState) => state.villains
  35. );
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top