feat(events): Adds AcknowledgableEvent
This commit is contained in:
parent
6d7a0e7cfb
commit
b82ab7dbc4
18 changed files with 228 additions and 77 deletions
40
source/Events/EventHandler.types.ts
Normal file
40
source/Events/EventHandler.types.ts
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import {AcknowledgableEvent} from "./AcknowledgableEvent";
|
||||
|
||||
export enum EventType {
|
||||
Normal,
|
||||
TimeBased,
|
||||
Acknowledge,
|
||||
}
|
||||
|
||||
export interface BaseEvent {
|
||||
type: EventType
|
||||
}
|
||||
export interface NormalEvent extends BaseEvent {
|
||||
type: EventType.Normal
|
||||
}
|
||||
|
||||
export interface AcknowledgeEvent extends BaseEvent {
|
||||
type: EventType.Acknowledge,
|
||||
isAcknowledged(): boolean,
|
||||
handleUnacknowledgement(): void
|
||||
}
|
||||
|
||||
export type HandlerEvents = NormalEvent | AcknowledgeEvent
|
||||
|
||||
export interface TimedEvent extends BaseEvent {
|
||||
type: EventType.TimeBased,
|
||||
configuration: EventConfiguration,
|
||||
cronExpression: string,
|
||||
execute: () => void
|
||||
}
|
||||
|
||||
|
||||
export type EventConfiguration = {
|
||||
name: string,
|
||||
maxExecutions?: number,
|
||||
}
|
||||
|
||||
export type EventEntry<T = any> = {
|
||||
method: (event: T) => void,
|
||||
persistent?: boolean
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue