import { Injectable } from '@angular/core';
import { CanDeactivate } from '@angular/router';
import { Observable, of } from 'rxjs';
import { LinkPageComponent } from './link-page.component';

@Injectable({
  providedIn: 'root'
})
export class LeaveGuard implements CanDeactivate<LinkPageComponent> {

  public canDeactivate(component:LinkPageComponent): Observable<boolean> {
    let isLive = localStorage.getItem('isLive');
    // console.log(isLive);
    if(isLive){
      return of(false);
    }else{
      return of(true);
    }
  }
}