From 5dffe35ea18a2dfed4c5f74b475556900ec9e606 Mon Sep 17 00:00:00 2001 From: Philip Molares Date: Sat, 24 Sep 2022 18:52:02 +0200 Subject: [PATCH] docs: add documentation about events Signed-off-by: Philip Molares Signed-off-by: Tilman Vatteroth --- docs/content/dev/events.md | 9 +++++++++ src/events.ts | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 docs/content/dev/events.md diff --git a/docs/content/dev/events.md b/docs/content/dev/events.md new file mode 100644 index 000000000..17a3f409a --- /dev/null +++ b/docs/content/dev/events.md @@ -0,0 +1,9 @@ +In HedgeDoc we use an event system based on [EventEmitter2][eventemitter2]. It's used to reduce circular dependencies between different services and inform these services about changes. + +HedgeDoc's system is basically [the system NestJS offers][nestjs/eventemitter]. +The config for the `EventEmitterModule` is stored in `events.ts` and exported as `eventModuleConfig`. +In the same file enums for the event keys are defined. Each of these events is expected to be sent with an additional value. In the enum defintion a comment should tell you what exactly this value should be. + +[eventemitter2]: https://github.com/EventEmitter2/EventEmitter2 +[nestjs/eventemitter]: https://docs.nestjs.com/techniques/events + diff --git a/src/events.ts b/src/events.ts index 836450fc3..c6cf9d986 100644 --- a/src/events.ts +++ b/src/events.ts @@ -15,6 +15,6 @@ export const eventModuleConfig = { }; export enum NoteEvent { - PERMISSION_CHANGE = 'note.permission_change', - DELETION = 'note.deletion', + PERMISSION_CHANGE = 'note.permission_change' /** noteId: The id of the [@link Note], which permissions are changed. **/, + DELETION = 'note.deletion' /** noteId: The id of the [@link Note], which is being deleted. **/, }