import { Component , OnInit } from '@angular/core' ; import { combineLatest } from 'rxjs' ; import { filter , mergeMap } from 'rxjs/operators' ; import { AuthenticationService , ProjectService } from '@core/services/index.service' ; import { ProfileModel , ProjectModel } from '@shared/models/index.model' ; @ Component ( { selector : 'dashboard-following' , templateUrl : './following.component.html' , styleUrls : [ './following.component.scss' ] , } ) export class FollowingComponent implements OnInit { public projects : ProjectModel [ ] = [ ] ; public title : string = 'Following projects list' ; param authenticationService param projectService constructor ( private authenticationService , private projectService ) { } /**
     * Finds the all projects details followed by logged in user
     */ ngOnInit ( ) { this . authenticationService . getCurrentUser ( ) . pipe ( filter ( ( profile ) => ! ! ( profile . following && profile . following . length ) ) , mergeMap ( ( profile ) => combineLatest ( ... profile . following . map ( ( uid ) => this . projectService . findOneById ( uid ) ) ) ) ) . subscribe ( ( projects ) => this . projects = projects ) ; } }