Ejemplo n.º 1
0
export function rootReducer (state: AppBackgroundState, action: Action) {
  if (action.type === 'SET_NEW_STATE') {
      state = Object.assign({}, state, action.payload);
  }
  if (!environment.production) {
    return compose(storeLogger(), combineReducers)(appBackgroundState)(state, action);
  } else {
    return compose(combineReducers)(appBackgroundState)(state, action);
  }
}
Ejemplo n.º 2
0
import { storeLogger } from 'ngrx-store-logger';
import { localStorageSync } from 'ngrx-store-localstorage';

import { IState as ICounterState, reducer as counterReducer } from './counter';
import { IState as IUserState, reducer as userReducer } from './user';
import { IState as IConfigState, reducer as configReducer } from './config';

// application state interface
export interface IState {
  router: RouterState;
  config: IConfigState;
  counter: ICounterState;
  user: IUserState;
}

// app level reducers
export const reducers = {
  router: routerReducer,
  config: configReducer,
  counter: counterReducer,
  user: userReducer
};

// root reducer
export const reducer: ActionReducer<IState> = compose(
  storeLogger(),
  storeFreeze,
  localStorageSync(keys(reducers), true),
  combineReducers
)(reducers);
 public static isLoading(): (selector: Observable<AppState>) => Observable<boolean> {
   return compose(this._isLoading(), this.getAuthState());
 }
 /**
  * Every reducer module exports selector functions, however child reducers
  * have no knowledge of the overall state tree. To make them useable, we
  * need to make new selectors that wrap them.
  *
  * Once again our compose function comes in handy. From right to left, we
  * first select the auths state then we pass the state to the auth
  * reducer's _getAuthItems selector, finally returning an observable
  * of search results.
  */
 public static getErrorMessage(): (selector: Observable<AppState>) => Observable<string> {
   return compose(this._getErrorMessage(), this.getAuthState());
 }
Ejemplo n.º 5
0
export function isCubeInCollection(id: string) {
  return compose(fromCubesCollection.isCubeInCollection(id), getCubesCollectionState());
}
Ejemplo n.º 6
0
export function getCollectionCubeIds() {
  return compose(fromCubesCollection.getCubeIds(), getCollectionState());
}
Ejemplo n.º 7
0
export function getCubesCollectionLoading() {
  return compose(fromCubesCollection.getLoading(), getCubesCollectionState());
}
Ejemplo n.º 8
0
export function getCubesSearchQuery() {
  return compose(fromCubesSearch.getQuery(), getCubesSearchState());
}
Ejemplo n.º 9
0
import { compose } from '@ngrx/core/compose';

import * as fromMissingWord from './missing-word-exercise/missing-word-exercise.reducer';
import { getSelectedExerciseState } from './exercises.reducer';

export { ExercisesRoutes } from './exercises.routes';
export { ExercisesComponent } from './exercises.component';
export { exercisesReducer } from './exercises.reducer';

export const getSelectedExerciseSentences = compose(fromMissingWord.getMissingWordsSentences, getSelectedExerciseState);
export const getSelectedExerciseMissingWordsAnswers = compose(fromMissingWord.getMissingWordsAnswers, getSelectedExerciseState);
export const getSelectedExerciseSentencesNums = compose(fromMissingWord.getMissingWordsNums, getSelectedExerciseState);
export const getSelectedExerciseMissingWords = compose(fromMissingWord.getMissingWords, getSelectedExerciseState);
export const isSelectedExerciseValidated = compose(fromMissingWord.isValidated, getSelectedExerciseState);
Ejemplo n.º 10
0
import { compose } from "@ngrx/core/compose";
// reducers
import { videos, EchoesVideos } from './youtube-videos';
import { player, YoutubePlayerState, PlayerActions} from './youtube-player';
import { nowPlaylist, YoutubeMediaPlaylist, NowPlaylistActions} from './now-playlist';
import { user, UserProfile } from './user-manager';
import { search, PlayerSearch} from './player-search';
import { localStorageSync } from './ngrx-store-localstorage';

/**
 * As mentioned, we treat each reducer like a table in a database. This means
 * our top level state interface is just a map of keys to inner state types.
 */
export interface EchoesState {
  videos: EchoesVideos;
  player: YoutubePlayerState;
  nowPlaylist: YoutubeMediaPlaylist;
  user: UserProfile;
  search: PlayerSearch;
}

export const actions = [
  NowPlaylistActions,
  PlayerActions
];

export default compose(
  localStorageSync(['videos', 'player', 'nowPlaylist', 'search'], true),
  combineReducers
)({ videos, player, nowPlaylist, user, search });