import { NotificationsSetup , Toast , ToastInput , ErrorToastOptions , } from 'opensearch-dashboards/public' ; export class ToastNotifications { public list : Toast [ ] = [ ] ; private onChangeCallback ? : ( ) => void ; constructor ( private readonly toasts ) { toasts . get$ ( ) . subscribe ( ( list ) => { this . list = list ; if ( this . onChangeCallback ) { this . onChangeCallback ( ) ; } } ) ; } public onChange = ( callback ) => { this . onChangeCallback = callback ; } ; public add = ( toastOrTitle ) => this . toasts . add ( toastOrTitle ) ; public remove = ( toast ) => this . toasts . remove ( toast ) ; public addSuccess = ( toastOrTitle ) => this . toasts . addSuccess ( toastOrTitle ) ; public addWarning = ( toastOrTitle ) => this . toasts . addWarning ( toastOrTitle ) ; public addDanger = ( toastOrTitle ) => this . toasts . addDanger ( toastOrTitle ) ; public addError = ( error , options ) => this . toasts . addError ( error , options ) ; }