1 import { firstValueFrom, Subject } from 'rxjs'
2 import { Injectable } from '@angular/core'
4 type ConfirmOptions = {
8 expectedInputValue?: string
9 confirmButtonText?: string
13 export class ConfirmService {
14 showConfirm = new Subject<ConfirmOptions>()
15 confirmResponse = new Subject<boolean>()
17 confirm (message: string, title = '', confirmButtonText?: string) {
18 this.showConfirm.next({ title, message, confirmButtonText })
20 return firstValueFrom(this.confirmResponse.asObservable())
23 confirmWithInput (message: string, inputLabel: string, expectedInputValue: string, title = '', confirmButtonText?: string) {
24 this.showConfirm.next({ title, message, inputLabel, expectedInputValue, confirmButtonText })
26 return firstValueFrom(this.confirmResponse.asObservable())