-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Event-bus ( WIP ) #250
base: main
Are you sure you want to change the base?
Event-bus ( WIP ) #250
Conversation
Coverage Report
File Coverage
|
* Listen to the note related events | ||
*/ | ||
EventBus.getInstance().addEventListener(NOTE_ADDED_EVENT_NAME, async (event) => { | ||
const { noteId, userId } = (event as CustomEvent<{ noteId: number; userId: number }>).detail; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we get rid of this casting? Maybe we can declare EventMap. Example:
https://github.com/codex-team/notes.web/blob/main/src/domain/event-bus/index.ts#L14-L29
super(NOTE_VISITED_EVENT_NAME, { detail: { noteId, | ||
userId } }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bad line break
super(NOTE_VISITED_EVENT_NAME, { detail: { noteId, | |
userId } }); | |
super(NOTE_VISITED_EVENT_NAME, { | |
detail: { | |
noteId, | |
userId | |
} | |
}); |
/** | ||
* Note visited event | ||
*/ | ||
export class NoteVisitedEvent extends CustomEvent<{ noteId: number; userId: number }> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export class NoteVisitedEvent extends CustomEvent<{ noteId: number; userId: number }> { | |
export class NoteVisitedEvent extends CustomEvent<{ noteId: Note['id']; userId: User['id'] }> { |
Working on event-bus, I tried to keep it in domain layer only and cover noteVisits and noteSettings.
But had to use noteSettings directly from presentation layer in getting the role of user to determine whether he can edit the note or not.
Other than that, it is fine.