diff --git a/packages/webamp-modern-2/src/skin/AudioPlayer.ts b/packages/webamp-modern-2/src/skin/AudioPlayer.ts index 33d449d9..44fdfe69 100644 --- a/packages/webamp-modern-2/src/skin/AudioPlayer.ts +++ b/packages/webamp-modern-2/src/skin/AudioPlayer.ts @@ -1,26 +1,4 @@ -import { clamp } from "../utils"; - -class Emitter { - _cbs: { [event: string]: Array<() => void> } = {}; - on(event: string, cb: () => void) { - if (this._cbs[event] == null) { - this._cbs[event] = []; - } - this._cbs[event].push(cb); - return () => { - this._cbs[event] = this._cbs[event].filter((c) => c !== cb); - }; - } - trigger(event: string) { - const subscriptions = this._cbs[event]; - if (subscriptions == null) { - return; - } - for (const cb of subscriptions) { - cb(); - } - } -} +import { clamp, Emitter } from "../utils"; export class AudioPlayer { _input: HTMLInputElement = document.createElement("input"); diff --git a/packages/webamp-modern-2/src/utils.ts b/packages/webamp-modern-2/src/utils.ts index 33254292..828c5ece 100644 --- a/packages/webamp-modern-2/src/utils.ts +++ b/packages/webamp-modern-2/src/utils.ts @@ -79,3 +79,25 @@ export function findLast( } } } + +export class Emitter { + _cbs: { [event: string]: Array<() => void> } = {}; + on(event: string, cb: () => void) { + if (this._cbs[event] == null) { + this._cbs[event] = []; + } + this._cbs[event].push(cb); + return () => { + this._cbs[event] = this._cbs[event].filter((c) => c !== cb); + }; + } + trigger(event: string) { + const subscriptions = this._cbs[event]; + if (subscriptions == null) { + return; + } + for (const cb of subscriptions) { + cb(); + } + } +}