import { Injectable , Injector } from '@angular/core' ; import { Observable } from 'rxjs' ; import { OverlayModalService } from '../../services/ux/overlay-modal' ; import { PublisherSearchModalComponent } from '../components/publisher-search-modal/publisher-search-modal.component' ; @ Injectable ( ) export class PublisherSearchModalService { param overlayModal constructor ( protected overlayModal ) { } param injector present ( injector , publisher ) { return new Observable < string > ( subscriber => { const data = { publisher : publisher , } ; let open = true ; this . overlayModal . create ( PublisherSearchModalComponent , data , { wrapperClass : 'm-modalV2__wrapper' , onSearch : query => { subscriber . next ( query ) ; this . overlayModal . dismiss ( ) ; } , onDismissIntent : ( ) => { this . overlayModal . dismiss ( ) ; } , } , injector ) . onDidDismiss ( ( ) => { open = false ; subscriber . complete ( ) ; } ) . present ( ) ; return ( ) => { if ( open ) { this . overlayModal . dismiss ( ) ; } } ; } ) ; } }