super selectOne

This commit is contained in:
insanity 2018-05-25 21:41:29 +09:00
parent 2cc645b116
commit f004270fbe
2 changed files with 10 additions and 7 deletions

View File

@ -13,7 +13,7 @@ import { RPCClientError } from '@loafer/ng-rpc';
})
export class ProbeDetailContainerComponent implements OnInit {
@Input() probeHostID;
@Input() probeHostID: number;
@Output() discovery = new EventEmitter<number>();
probeHost$: Observable<ProbeHost>;
error$: Observable<RPCClientError>;
@ -22,10 +22,10 @@ export class ProbeDetailContainerComponent implements OnInit {
private store: Store<ProbeStore.State>,
private route: ActivatedRoute,
) {
this.probeHost$ = store.pipe(select(ProbeSelector.selectOne(this.probeHostID)));
}
ngOnInit() {
this.probeHost$ = this.store.pipe(select(ProbeSelector.selectOne(this.probeHostID)));
this.store.dispatch(new ProbeStore.Read(this.probeHostID));
}

View File

@ -8,23 +8,26 @@ import { StateSelector } from '@overflow/core/ngrx/store';
import { MODULE } from '../probe.constant';
import * as ProbeStore from './entity/probe';
import * as ProbeEntityStore from './entity/probe';
import * as ProbeListContainerStore from './container/probe-list';
export interface State {
probes: ProbeStore.State;
probes: ProbeEntityStore.State;
probe_list_pending: ProbeListContainerStore.State;
}
export const REDUCERS = {
probes: ProbeStore.reducer,
probes: ProbeEntityStore.reducer,
probe_list_pending: ProbeListContainerStore.reducer,
};
export const EFFECTS = [
ProbeStore.Effects,
ProbeEntityStore.Effects,
];
export const selectState = createFeatureSelector<State>(MODULE.name);
export const ProbeSelector = ProbeStore.getSelectors(createSelector(
export const ProbeSelector = ProbeEntityStore.getSelectors(createSelector(
selectState,
(state: State) => state.probes
));