import { RPCClientError } from '@loafer/ng-rpc';
import { ProbeHost } from '@overflow/commons-typescript/model/probe';
import { Selector, createSelector } from '@ngrx/store';
import { createEntityAdapter, EntityState } from '@loafer/ng-entity';

export const probeListContainerAdapter = createEntityAdapter<ProbeHost, RPCClientError>();
export interface State extends EntityState<ProbeHost, RPCClientError> {
  pending: boolean;
}
export const initialState: State = probeListContainerAdapter.getInitialState({
  pending: false,
});

export function getSelectors<S>(selector: Selector<any, State>) {
  return {
    ...probeListContainerAdapter.getSelectors(selector),
    selectPending: createSelector(selector, (state: State) => state.pending),
  };
}


