aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/standalone/player/events.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-08-17 14:42:53 +0200
committerChocobozzz <me@florianbigard.com>2021-08-18 08:35:06 +0200
commit9df52d660feb722404be00a50f3c8a612bec1c15 (patch)
treedde52880fa012874d24c60f64eb596b0a789cc8b /client/src/standalone/player/events.ts
parentadb8809d43648ea0a64d6845bb39aa3bd0e005a6 (diff)
downloadPeerTube-9df52d660feb722404be00a50f3c8a612bec1c15.tar.gz
PeerTube-9df52d660feb722404be00a50f3c8a612bec1c15.tar.zst
PeerTube-9df52d660feb722404be00a50f3c8a612bec1c15.zip
Migrate client to eslint
Diffstat (limited to 'client/src/standalone/player/events.ts')
-rw-r--r--client/src/standalone/player/events.ts14
1 files changed, 7 insertions, 7 deletions
diff --git a/client/src/standalone/player/events.ts b/client/src/standalone/player/events.ts
index 28a13c727..7a8e9dbec 100644
--- a/client/src/standalone/player/events.ts
+++ b/client/src/standalone/player/events.ts
@@ -1,7 +1,7 @@
1import { EventHandler } from './definitions' 1import { EventHandler } from './definitions'
2 2
3interface PlayerEventRegistrar { 3interface PlayerEventRegistrar {
4 registrations: Function[] 4 registrations: EventHandler<any>[]
5} 5}
6 6
7interface PlayerEventRegistrationMap { 7interface PlayerEventRegistrationMap {
@@ -20,28 +20,28 @@ export class EventRegistrar {
20 20
21 public registerTypes (names: string[]) { 21 public registerTypes (names: string[]) {
22 for (const name of names) { 22 for (const name of names) {
23 this.eventRegistrations[ name ] = { registrations: [] } 23 this.eventRegistrations[name] = { registrations: [] }
24 } 24 }
25 } 25 }
26 26
27 public fire<T> (name: string, event: T) { 27 public fire<T> (name: string, event: T) {
28 this.eventRegistrations[ name ].registrations.forEach(x => x(event)) 28 this.eventRegistrations[name].registrations.forEach(x => x(event))
29 } 29 }
30 30
31 public addListener<T> (name: string, handler: EventHandler<T>) { 31 public addListener<T> (name: string, handler: EventHandler<T>) {
32 if (!this.eventRegistrations[ name ]) { 32 if (!this.eventRegistrations[name]) {
33 console.warn(`PeerTube: addEventListener(): The event '${name}' is not supported`) 33 console.warn(`PeerTube: addEventListener(): The event '${name}' is not supported`)
34 return false 34 return false
35 } 35 }
36 36
37 this.eventRegistrations[ name ].registrations.push(handler) 37 this.eventRegistrations[name].registrations.push(handler)
38 return true 38 return true
39 } 39 }
40 40
41 public removeListener<T> (name: string, handler: EventHandler<T>) { 41 public removeListener<T> (name: string, handler: EventHandler<T>) {
42 if (!this.eventRegistrations[ name ]) return false 42 if (!this.eventRegistrations[name]) return false
43 43
44 this.eventRegistrations[ name ].registrations = this.eventRegistrations[ name ].registrations.filter(x => x === handler) 44 this.eventRegistrations[name].registrations = this.eventRegistrations[name].registrations.filter(x => x === handler)
45 45
46 return true 46 return true
47 } 47 }