chore: convert extension apis to TypeScript (#18688)
Converts extensions-related files to TS
This commit is contained in:
parent
6e327184bd
commit
ffb53405fb
6 changed files with 66 additions and 85 deletions
20
lib/renderer/extensions/event.ts
Normal file
20
lib/renderer/extensions/event.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
export class Event {
|
||||
private listeners: Function[] = []
|
||||
|
||||
addListener (callback: Function) {
|
||||
this.listeners.push(callback)
|
||||
}
|
||||
|
||||
removeListener (callback: Function) {
|
||||
const index = this.listeners.indexOf(callback)
|
||||
if (index !== -1) {
|
||||
this.listeners.splice(index, 1)
|
||||
}
|
||||
}
|
||||
|
||||
emit (...args: any[]) {
|
||||
for (const listener of this.listeners) {
|
||||
listener(...args)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue