staff_data/apps/server/src/utils/event-bus.ts

32 lines
741 B
TypeScript
Raw Normal View History

2024-12-30 08:26:40 +08:00
import mitt from 'mitt';
2025-02-24 08:51:44 +08:00
import { ObjectType, UserProfile, MessageDto, VisitType } from '@nice/common';
2024-12-30 08:26:40 +08:00
export enum CrudOperation {
CREATED,
UPDATED,
2025-02-24 08:51:44 +08:00
DELETED,
2024-12-30 08:26:40 +08:00
}
type Events = {
2025-02-24 08:51:44 +08:00
genDataEvent: { type: 'start' | 'end' };
markDirty: {
objectType: string;
id: string;
staff?: UserProfile;
subscribers?: string[];
};
updateVisitCount: {
id: string;
objectType: ObjectType;
visitType: VisitType | string;
};
updatePostState: {
id: string;
};
2025-02-25 08:25:54 +08:00
updateTotalCourseViewCount: {
visitType: VisitType | string;
};
2025-02-24 08:51:44 +08:00
onMessageCreated: { data: Partial<MessageDto> };
dataChanged: { type: string; operation: CrudOperation; data: any };
2024-12-30 08:26:40 +08:00
};
const EventBus = mitt<Events>();
export default EventBus;