import { Observable , Subject } from 'rxjs' ; import { IService } from '../interfaces/interface.service' ; import ServiceElectronIpc , { IPC , Subscription } from './service.electron.ipc' ; export class FilterOpenerService implements IService { private _subscriptions : { [ key ] : Subscription ; } = { } ; private _subjects = { openFilters : new Subject < string | undefined > ( ) , } ; constructor ( ) { } public init ( ) { return new Promise ( ( resolve ) => { this . _subscriptions . FiltersOpen = ServiceElectronIpc . subscribe ( IPC . FiltersOpen , this . _onFiltersOpen . bind ( this ) ) ; resolve ( ) ; } ) ; } public getName ( ) { return 'FilterOpenerService' ; } public destroy ( ) { return new Promise ( ( resolve ) => { Object . keys ( this . _subscriptions ) . forEach ( ( key ) => { this . _subscriptions [ key ] . destroy ( ) ; } ) ; resolve ( ) ; } ) ; } public getObservable ( ) { return { openFilters : this . _subjects . openFilters . asObservable ( ) , } ; } private _onFiltersOpen ( request ) { this . _subjects . openFilters . next ( request . file ) ; } } export default new FilterOpenerService ( ) ;