import {
  createSelector,
  createFeatureSelector,
  ActionReducerMap,
} from '@ngrx/store';

import { MODULE } from '../infra.constant';

import * as ListStore from './list';
import * as DetailStore from './detail';
import { StateSelector } from 'packages/core/ngrx/store';

export interface State {
  list: ListStore.State;
  sensor: DetailStore.State;
}

export const REDUCERS = {
  list: ListStore.reducer,
  sensor: DetailStore.reducer
};

export const EFFECTS = [
  ListStore.Effects,
  DetailStore.Effects
];

export const selectInfraState = createFeatureSelector<State>(MODULE.name);

export const ListSelector = new StateSelector<ListStore.State>(createSelector(
  selectInfraState,
  (state: State) => state.list
));

export const DetailSelector = new StateSelector<DetailStore.State>(createSelector(
  selectInfraState,
  (state: State) => state.sensor
));
