The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/client/lib/toast.ts

19 lines
569 B

import { Emitter } from '@rocket.chat/emitter';
export type ToastMessagePayload = {
type: 'success' | 'info' | 'warning' | 'error';
message: string | Error;
title?: string;
options?: object;
};
const emitter = new Emitter<{
notify: ToastMessagePayload;
}>();
export const dispatchToastMessage = (payload: ToastMessagePayload): void => {
// TODO: buffer it if there is no subscriber
emitter.emit('notify', payload);
};
export const subscribeToToastMessages = (callback: (payload: ToastMessagePayload) => void): (() => void) => emitter.on('notify', callback);