import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; import { GeoInfoService } from './geo-info.service'; import { AppState } from '../../../../../../app/reducers/index'; import { Store } from '@ngrx/store'; import { take } from 'rxjs/operators'; @Component({ selector: 'app-geo-info', templateUrl: 'geo-info.component.html', styleUrls: ['geo-info.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush }) export class GeoInfoComponent implements OnInit { model$; hideInfo () { this.geoInfoService.hideInfo(); } revert () { this.hideInfo(); this.model$ .pipe( take(1) ) .subscribe((model) => { this.geoInfoService.revert(model.revertKeys); }); } constructor (private _store: Store, private geoInfoService: GeoInfoService) {} ngOnInit() { this.model$ = this._store.pipe(this.geoInfoService.getModel); } }