ldc-showroom/plugins/emitter.ts

18 lines
330 B
TypeScript
Raw Permalink Normal View History

import mitt from "mitt";
type Events = {
toast: {message:string, type:ToastTypeEnum, title: string|null};
};
const emitter = mitt<Events>();
const $bus = {
$on: emitter.on,
$emit: emitter.emit,
};
export type $Bus = typeof $bus;
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.provide("bus", $bus);
});