mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
improve media mime type inferring + added uploadToEntity in media api
This commit is contained in:
@@ -6,6 +6,7 @@ export type RegisterListenerConfig =
|
||||
| {
|
||||
mode?: ListenerMode;
|
||||
once?: boolean;
|
||||
id?: string;
|
||||
};
|
||||
|
||||
export interface EmitsEvents {
|
||||
@@ -124,6 +125,14 @@ export class EventManager<
|
||||
addListener(listener: EventListener) {
|
||||
this.throwIfEventNotRegistered(listener.event);
|
||||
|
||||
if (listener.id) {
|
||||
const existing = this.listeners.find((l) => l.id === listener.id);
|
||||
if (existing) {
|
||||
console.warn(`Listener with id "${listener.id}" already exists.`);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
this.listeners.push(listener);
|
||||
return this;
|
||||
}
|
||||
@@ -140,6 +149,9 @@ export class EventManager<
|
||||
if (config.once) {
|
||||
listener.once = true;
|
||||
}
|
||||
if (config.id) {
|
||||
listener.id = `${event.slug}-${config.id}`;
|
||||
}
|
||||
this.addListener(listener as any);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user