Skip to content

Commit

Permalink
feat: create domain event interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonardoCamargo31 committed Oct 29, 2023
1 parent afbd2f4 commit 57abdab
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/domain/event/@shared/event-dispatcher-interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { EventHandlerInterface } from './event-handler-interface'
import { EventInterface } from './event-interface'

export interface EventDispatcherInterface {
notify: (event: EventInterface) => void
register: (eventName: string, eventHandler: EventHandlerInterface) => void
unregister: (eventName: string, eventHandler: EventHandlerInterface) => void
unregisterAll: () => void
}
8 changes: 8 additions & 0 deletions src/domain/event/@shared/event-handler-interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { EventInterface } from './event-interface'
// todo event handler tem que receber um evento
// vamos garantir que é do tipo EventInterface
// com o uso do generic <T>
// com valor padrão sendo EventInterface
export interface EventHandlerInterface<T extends EventInterface=EventInterface> {
handler: (event: T) => void
}
4 changes: 4 additions & 0 deletions src/domain/event/@shared/event-interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface EventInterface {
dataTimeOccurred: Date
eventData: any
}

0 comments on commit 57abdab

Please sign in to comment.