import { EventEmitter } from 'events';
import { TypedEmitter } from '@wix/bex-core/events';
import { ToastConfig } from '@wix/bex-core';

export const showToast = new EventEmitter() as TypedEmitter<{
  toastConfig: () => ToastConfig;
}>;

export const getToast = (biName: string) =>
  showToast
    .listeners('toastConfig')
    .map((e) => e())
    .find((e) => e.biName === biName);
