import { Component , Input , OnDestroy , OnInit } from '@angular/core' ; import { Observable , Subscription } from 'rxjs' ; import { Actions , ofType } from '@ngrx/effects' ; import { MapActionTypes , SetProgressBarAction } from '../../actions/map.actions' ; import { filter , map , tap } from 'rxjs/operators' ; @ Component ( { selector : 'ansyn-imagery-tile-progress' , templateUrl : './imagery-tile-progress.component.html' , styleUrls : [ './imagery-tile-progress.component.less' ] } ) export class ImageryTileProgressComponent implements OnInit , OnDestroy { @ Input ( ) mapId ; @ Input ( ) lowered ; private _subscriptions : Subscription [ ] = [ ] ; progress$ : Observable < any > = this . actions$ . pipe ( ofType ( MapActionTypes . VIEW . SET_PROGRESS_BAR ) , filter ( ( action ) => action . payload . mapId === this . mapId ) , map ( ( action ) => action . payload . progress ) , tap ( ( progress ) => this . progress = progress ) ) ; progress ; constructor ( public actions$ ) { } ngOnInit ( ) { this . _subscriptions . push ( this . progress$ . subscribe ( ) ) ; } ngOnDestroy ( ) { this . _subscriptions . forEach ( observable$ => observable$ . unsubscribe ( ) ) ; } }