mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-03 17:59:37 +02:00
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import { MChannel, MVideo, MVideoImmutable } from '@server/types/models/index.js'
|
|
import { EventEmitter } from 'events'
|
|
|
|
export interface PeerTubeInternalEvents {
|
|
'video-created': (options: { video: MVideo }) => void
|
|
'video-updated': (options: { video: MVideo }) => void
|
|
'video-deleted': (options: { video: MVideo }) => void
|
|
|
|
'channel-created': (options: { channel: MChannel }) => void
|
|
'channel-updated': (options: { channel: MChannel }) => void
|
|
'channel-deleted': (options: { channel: MChannel }) => void
|
|
|
|
'chapters-updated': (options: { video: MVideoImmutable }) => void
|
|
}
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
|
declare interface InternalEventEmitter {
|
|
on<U extends keyof PeerTubeInternalEvents>(
|
|
event: U,
|
|
listener: PeerTubeInternalEvents[U]
|
|
): this
|
|
|
|
emit<U extends keyof PeerTubeInternalEvents>(
|
|
event: U,
|
|
...args: Parameters<PeerTubeInternalEvents[U]>
|
|
): boolean
|
|
}
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
|
class InternalEventEmitter extends EventEmitter {
|
|
private static instance: InternalEventEmitter
|
|
|
|
static get Instance () {
|
|
return this.instance || (this.instance = new this())
|
|
}
|
|
}
|
|
|
|
export {
|
|
InternalEventEmitter
|
|
}
|