import { Injectable } from '@angular/core' ; import { Observable , Subject } from 'rxjs' ; import { take } from 'rxjs/operators' ; import { ObIHttpApiRequest } from './http-api-interceptor.model' ; /**
 * Provides access to the Oblique HTTP Interceptor events.
 */ @ Injectable ( { providedIn : 'root' } ) export class ObHttpApiInterceptorEvents { protected requested = new Subject < ObIHttpApiRequest > ( ) ; protected expired = new Subject < void > ( ) ; private readonly requestIntercepted$ = this . requested . asObservable ( ) ; private readonly sessionExpired$ = this . expired . asObservable ( ) ; /**
     * This will be fed with `requested` events
     */ get requestIntercepted ( ) : Observable < ObIHttpApiRequest > { return this . requestIntercepted$ ; } /**
     * This will be fed with `expired` events
     */ get sessionExpired ( ) : Observable < void > { return this . sessionExpired$ ; } /**
     * Fire an `expire` event
     */ public sessionExpire ( ) { this . expired . next ( ) ; } /**
     * Fire an `requesteed` event
     */ public requestIntercept ( request ) { this . requested . next ( request ) ; } public deactivateSpinnerOnNextAPICalls ( number = 1 ) { this . requestIntercepted . pipe ( take ( number ) ) . subscribe ( ( evt ) => { evt . spinner = false ; } ) ; } public deactivateNotificationOnNextAPICalls ( number = 1 ) { this . requestIntercepted . pipe ( take ( number ) ) . subscribe ( ( evt ) => { evt . notification . active = false ; } ) ; } public deactivateOnNextAPICalls ( number = 1 ) { this . requestIntercepted . pipe ( take ( number ) ) . subscribe ( ( evt ) => { evt . notification . active = false ; evt . spinner = false ; } ) ; } }