import { Injectable } from '@angular/core' ; import { BehaviorSubject , Subscription } from 'rxjs' ; import { Router , NavigationEnd } from '@angular/router' ; import { filter } from 'rxjs/operators' ; @ Injectable ( ) export class PageLayoutService { routerSubscription : Subscription ; hasRightPane$ : BehaviorSubject < boolean > = new BehaviorSubject ( false ) ; isFullWidth$ : BehaviorSubject < boolean > = new BehaviorSubject ( false ) ; hasTopbarBorder$ : BehaviorSubject < boolean > = new BehaviorSubject ( true ) ; hasTopbarBackground$ : BehaviorSubject < boolean > = new BehaviorSubject ( true ) ; constructor ( private router ) { this . routerSubscription = this . router . events . pipe ( filter ( e => e instanceof NavigationEnd ) ) . subscribe ( data => { this . reset ( ) ; } ) ; } return useFullWidth ( ) { setTimeout ( ( ) => this . isFullWidth$ . next ( true ) ) ; } cancelFullWidth ( ) { setTimeout ( ( ) => this . isFullWidth$ . next ( false ) ) ; } useTopbarBorder ( ) { setTimeout ( ( ) => this . hasTopbarBorder$ . next ( true ) ) ; } removeTopbarBorder ( ) { setTimeout ( ( ) => this . hasTopbarBorder$ . next ( false ) ) ; } useTopbarBackground ( ) { setTimeout ( ( ) => this . hasTopbarBackground$ . next ( true ) ) ; } removeTopbarBackground ( ) { setTimeout ( ( ) => this . hasTopbarBackground$ . next ( false ) ) ; } reset ( ) { setTimeout ( ( ) => { this . isFullWidth$ . next ( false ) ; this . hasTopbarBorder$ . next ( true ) ; this . hasTopbarBackground$ . next ( true ) ; } ) ; } }