import { Notification, NotificationSchema } from './types' import events from './events' let count = 0 const generateId = () => { const id = count count += 1 return id } type UserNotification = Omit, 'id' | 'group'> & Partial, 'group'>> const createNotifier = () => { return (notification: UserNotification, timeout?: number) => { const identifiedNotification = { ...notification, id: generateId(), group: notification.group || '', } as Notification events.emit('notify', { notification: identifiedNotification, timeout }) return () => events.emit('close', identifiedNotification.id) } } export default createNotifier