import { Compiler , Injectable , Injector } from '@angular/core' ; import { Subject } from 'rxjs' ; import { StackableModalEvent , StackableModalService , } from '../../../services/ux/stackable-modal.service' ; import { EarnModalComponent } from './earn-modal.component' ; @ Injectable ( ) export class EarnModalService { constructor ( private stackableModal , private compiler , private injector ) { } async open ( ) { const { EarnModalModule } = await import ( './earn-modal.module' ) ; const moduleFactory = await this . compiler . compileModuleAsync ( EarnModalModule ) ; const moduleRef = moduleFactory . create ( this . injector ) ; const componentFactory = moduleRef . instance . resolveComponent ( ) ; const onSuccess$ = new Subject ( ) ; const evt = await this . stackableModal . present ( EarnModalComponent , null , { wrapperClass : 'm-modalV2__wrapper' , onComplete : ( result ) => { onSuccess$ . next ( result ) ; onSuccess$ . complete ( ) ; this . stackableModal . dismiss ( ) ; } , onDismissIntent : ( ) => { this . stackableModal . dismiss ( ) ; } , } ) . toPromise ( ) ; return onSuccess$ . toPromise ( ) ; } }