import { Directive , HostBinding , OnDestroy } from '@angular/core' ; import { takeUntil } from 'rxjs/operators' ; import { ObOffCanvasService } from './off-canvas.service' ; import { Subject } from 'rxjs' ; @ Directive ( { selector : '.ob-off-canvas, ob-master-layout' } ) export class ObOffCanvasContainerDirective implements OnDestroy { @ HostBinding ( 'class.ob-off-canvas-in' ) open = false ; private readonly unsubscribe = new Subject ( ) ; constructor ( offCanvas ) { offCanvas . opened . pipe ( takeUntil ( this . unsubscribe ) ) . subscribe ( value => { this . open = value ; } ) ; } ngOnDestroy ( ) { this . unsubscribe . next ( ) ; this . unsubscribe . complete ( ) ; } }