dispatch lifecycle

This commit is contained in:
insanity 2018-05-27 15:52:27 +09:00
parent ddc091bdf5
commit c24dd61de1
4 changed files with 9 additions and 7 deletions

View File

@ -1,2 +1 @@
<div *ngIf="error">An error has occurred.</div>
<of-probe-detail [pending]="pending$ |async" [probeHost]="probeHost$ | async" (modify)="onModify($event)" (discovery)="onDiscovery($event)"></of-probe-detail> <of-probe-detail [pending]="pending$ |async" [probeHost]="probeHost$ | async" (modify)="onModify($event)" (discovery)="onDiscovery($event)"></of-probe-detail>

View File

@ -1,4 +1,4 @@
import { Component, OnInit, Input, AfterViewInit, Output, EventEmitter } from '@angular/core'; import { Component, OnInit, Input, AfterViewInit, Output, EventEmitter, AfterContentInit, OnChanges, SimpleChanges } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { ProbeHost, Probe } from '@overflow/commons-typescript/model/probe'; import { ProbeHost, Probe } from '@overflow/commons-typescript/model/probe';
import { Store, select } from '@ngrx/store'; import { Store, select } from '@ngrx/store';
@ -10,7 +10,7 @@ import { ActivatedRoute } from '@angular/router';
selector: 'of-probe-detail-container', selector: 'of-probe-detail-container',
templateUrl: './probe-detail-container.html', templateUrl: './probe-detail-container.html',
}) })
export class ProbeDetailContainerComponent implements OnInit { export class ProbeDetailContainerComponent implements OnInit, OnChanges {
@Input() probeHostID: number; @Input() probeHostID: number;
@Output() discovery = new EventEmitter<number>(); @Output() discovery = new EventEmitter<number>();
@ -28,6 +28,9 @@ export class ProbeDetailContainerComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.probeHost$ = this.store.pipe(select(ProbeSelector.selectOne(this.probeHostID))); this.probeHost$ = this.store.pipe(select(ProbeSelector.selectOne(this.probeHostID)));
}
ngOnChanges(changes: SimpleChanges): void {
this.store.dispatch(new ProbeStore.Read(this.probeHostID)); this.store.dispatch(new ProbeStore.Read(this.probeHostID));
} }

View File

@ -13,13 +13,13 @@ import * as ProbeListContainerStore from './container/probe-list';
import * as ProbeDetailContainerStore from './container/probe-detail'; import * as ProbeDetailContainerStore from './container/probe-detail';
export interface State { export interface State {
probes: ProbeEntityStore.State; probe: ProbeEntityStore.State;
probe_list_container: ProbeListContainerStore.State; probe_list_container: ProbeListContainerStore.State;
probe_detail_container: ProbeDetailContainerStore.State; probe_detail_container: ProbeDetailContainerStore.State;
} }
export const REDUCERS = { export const REDUCERS = {
probes: ProbeEntityStore.reducer, probe: ProbeEntityStore.reducer,
probe_list_container: ProbeListContainerStore.reducer, probe_list_container: ProbeListContainerStore.reducer,
probe_detail_container: ProbeDetailContainerStore.reducer probe_detail_container: ProbeDetailContainerStore.reducer
}; };
@ -32,7 +32,7 @@ export const selectState = createFeatureSelector<State>(MODULE.name);
export const ProbeSelector = ProbeEntityStore.getSelectors(createSelector( export const ProbeSelector = ProbeEntityStore.getSelectors(createSelector(
selectState, selectState,
(state: State) => state.probes (state: State) => state.probe
)); ));
export const ProbeListContainerSelector = ProbeListContainerStore.getSelectors(createSelector( export const ProbeListContainerSelector = ProbeListContainerStore.getSelectors(createSelector(

View File

@ -5,7 +5,7 @@
export const environment = { export const environment = {
production: false, production: false,
restBaseURL: 'http://192.168.1.50:19080/webapp', restBaseURL: 'http://192.168.1.101:19080/webapp',
webappRPCConfig: { webappRPCConfig: {
url: 'ws://192.168.1.101:19090/webapp', url: 'ws://192.168.1.101:19090/webapp',
reconnectInterval: 5000, reconnectInterval: 5000,