import { catchError, map, tap } from 'rxjs/operators';
import { select, Store } from '@ngrx/store';
import { Vorgang } from './vorgang';
+import { increment, decrement, reset } from './actions/vorgang';
import { State } from './reducers/vorgang';
return this.gpsUrl + vbId + '/save';
}
+ increment() {
+ this.store.dispatch(increment());
+ }
+
+ decrement() {
+ this.store.dispatch(decrement());
+ }
+
+ reset() {
+ this.store.dispatch(reset());
+ }
+
Observable<number> observe() {
return this.store.pipe(select('vorgang'), map(vorgang => vorgang.counter));
}
import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
-import { Store } from '@ngrx/store';
-import { increment, decrement, reset } from '../actions/vorgang';
import { VorgangService } from '../vorgang.service';
-import { State } from '../reducers';
@Component({
selector: 'app-vorgang',
vorgang$: Observable<number>;
- constructor(
- private store: Store<{ vorgang: State }>,
- private service: VorgangService) {
+ constructor(private service: VorgangService) {
this.vorgang$ = service.observe();
}
}
increment() {
- this.store.dispatch(increment());
+ this.service.increment();
}
decrement() {
- this.store.dispatch(decrement());
+ this.service.decrement();
}
reset() {
- this.store.dispatch(reset());
+ this.service.reset();
}
}