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

import { StateSelector } from 'packages/core/ngrx/store';

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

import * as ListStore from './list';
import * as DetailStore from './detail';

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 sensorState = createFeatureSelector<State>(MODULE.name);

export const sensorListSelector = new StateSelector<ListStore.State>(createSelector(
  sensorState,
  (state: State) => state.list
));
export const sensorSelector = new StateSelector<DetailStore.State>(createSelector(
  sensorState,
  (state: State) => state.sensor
));

