import { Injectable } from '@angular/core' ; import { of } from 'rxjs' ; import { delay , tap } from 'rxjs/operators' ; import { SpinnerService , UserProfileService } from '../core' ; @ Injectable ( ) export class LoginService { constructor ( private spinnerService , private userProfileService ) { } login ( ) { return of ( true ) . pipe ( tap ( _ => this . spinnerService . show ( ) ) , delay ( 1000 ) , tap ( this . toggleLogState . bind ( this ) ) ) ; } logout ( ) { this . toggleLogState ( false ) ; } private toggleLogState ( val ) { this . userProfileService . isLoggedIn = val ; this . spinnerService . hide ( ) ; } }