import { Component , OnInit } from '@angular/core' ; import { Observable } from 'rxjs' ; import { User } from '../../auth/models/user.model' ; import { Store } from '@ngrx/store' ; import { AppState } from '../../reducers/index' ; import { getUser } from '../../auth/store/auth.selectors' ; import * as fromAuth from './../../auth/store/auth.actions' ; @ Component ( { selector : 'app-profile' , templateUrl : './profile.component.html' , styleUrls : [ './profile.component.scss' ] } ) export class ProfileComponent implements OnInit { user$ : Observable < User | null > ; constructor ( private store ) { } ngOnInit ( ) { this . user$ = this . store . select ( getUser ) ; } updateProfile ( userData ) { this . store . dispatch ( new fromAuth . UpdateProfile ( userData ) ) ; } logoutUser ( user ) { this . store . dispatch ( new fromAuth . LogoutRequested ( { user } ) ) ; } }