@xyo-network/module-events
Advanced tools
Comparing version 3.0.7 to 3.0.8
@@ -1,76 +0,3 @@ | ||
import { BaseParams, Base } from '@xylabs/object'; | ||
import { Promisable } from '@xylabs/promise'; | ||
type EventName = PropertyKey; | ||
type EventArgs = string | number | object; | ||
type EventData = { | ||
[key: EventName]: EventArgs; | ||
}; | ||
type EventUnsubscribeFunction = () => void; | ||
type EventAnyListener<TEventArgs extends EventArgs = EventArgs> = (eventName: EventName, eventData: TEventArgs) => Promisable<void>; | ||
type EventListener<TEventArgs extends EventArgs = EventArgs> = (eventData: TEventArgs) => Promisable<void>; | ||
interface EventFunctions<TEventData extends EventData> { | ||
eventData: TEventData; | ||
clearListeners(eventNames: keyof TEventData | (keyof TEventData)[]): void; | ||
emit<TEventName extends keyof TEventData>(eventName: TEventName, eventArgs: TEventData[TEventName]): Promise<void>; | ||
emitSerial<TEventName extends keyof TEventData>(eventName: TEventName, eventArgs: TEventData[TEventName]): Promise<void>; | ||
listenerCount(eventNames: keyof TEventData | (keyof TEventData)[]): number; | ||
off<TEventName extends keyof TEventData>(eventNames: TEventName | TEventName[], listener: EventListener<TEventData[TEventName]>): void; | ||
offAny(listener: EventAnyListener | Promise<void>): void; | ||
on<TEventName extends keyof TEventData>(eventNames: TEventName | TEventName[], listener: EventListener<TEventData[TEventName]>): EventUnsubscribeFunction; | ||
onAny(listener: EventAnyListener): EventUnsubscribeFunction; | ||
once<TEventName extends keyof TEventData>(eventName: TEventName, listener: EventListener<TEventData[TEventName]>): EventUnsubscribeFunction; | ||
} | ||
type DebugLogger = (type: string, debugName: string, eventName?: EventName, eventData?: EventArgs) => void; | ||
type EventListenerInfo<TEventArgs extends EventArgs = EventArgs> = { | ||
filter?: TEventArgs; | ||
listener: EventListener<TEventArgs>; | ||
}; | ||
type DebugOptions = { | ||
enabled?: boolean; | ||
logger?: DebugLogger; | ||
readonly name: string; | ||
}; | ||
type MetaEventData<TEventData extends EventData> = { | ||
listenerAdded: { | ||
eventName?: keyof TEventData; | ||
listener: EventListener<TEventData[keyof TEventData]> | EventAnyListener<TEventData[keyof TEventData]>; | ||
}; | ||
listenerRemoved: { | ||
eventName?: keyof TEventData; | ||
listener: EventListener<TEventData[keyof TEventData]> | EventAnyListener<TEventData[keyof TEventData]>; | ||
}; | ||
}; | ||
type EventsParams = BaseParams<{ | ||
readonly debug?: DebugOptions; | ||
}>; | ||
declare class Events<TEventData extends EventData = EventData> extends Base<EventsParams> implements EventFunctions<TEventData> { | ||
protected static anyMap: WeakMap<object, Set<EventAnyListener>>; | ||
protected static eventsMap: WeakMap<object, Map<PropertyKey, Set<EventListenerInfo<EventArgs>>>>; | ||
private static canEmitMetaEvents; | ||
private static isGlobalDebugEnabled; | ||
eventData: TEventData; | ||
constructor(params?: EventsParams); | ||
static get isDebugEnabled(): boolean; | ||
static set isDebugEnabled(newValue: boolean); | ||
get debug(): DebugOptions | undefined; | ||
clearListeners(eventNames: keyof TEventData | (keyof TEventData)[]): void; | ||
emit<TEventName extends keyof TEventData>(eventName: TEventName, eventArgs: TEventData[TEventName]): Promise<void>; | ||
emitMetaEvent<TEventName extends keyof MetaEventData<TEventData>>(eventName: TEventName, eventArgs: MetaEventData<TEventData>[TEventName]): Promise<void>; | ||
emitSerial<TEventName extends keyof TEventData>(eventName: TEventName, eventArgs: TEventData[TEventName]): Promise<void>; | ||
listenerCount(eventNames?: keyof TEventData | (keyof TEventData)[]): number; | ||
logIfDebugEnabled<TEventName extends EventName>(type: string, eventName?: TEventName, eventArgs?: EventArgs): void; | ||
off<TEventName extends keyof TEventData, TEventListener = EventListener<TEventData[TEventName]>>(eventNames: TEventName | TEventName[], listener: TEventListener): void; | ||
offAny(listener: EventAnyListener): void; | ||
on<TEventName extends keyof TEventData = keyof TEventData>(eventNames: TEventName | TEventName[], listener: EventListener<TEventData[TEventName]>, filter?: TEventData[TEventName]): () => void; | ||
onAny(listener: EventAnyListener): () => void; | ||
once<TEventName extends keyof TEventData>(eventName: TEventName, listener: EventListener<TEventData[TEventName]>): () => void; | ||
private emitInternal; | ||
private emitMetaEventInternal; | ||
private getListeners; | ||
private safeCallAnyListener; | ||
private safeCallListener; | ||
} | ||
export { type DebugLogger, type DebugOptions, type EventAnyListener, type EventArgs, type EventData, type EventFunctions, type EventListener, type EventListenerInfo, type EventName, type EventUnsubscribeFunction, Events, type EventsParams, type MetaEventData }; | ||
export * from './Events/index.ts'; | ||
export * from './model/index.ts'; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@xyo-network/module-events", | ||
"version": "3.0.7", | ||
"version": "3.0.8", | ||
"description": "Primary SDK for using XYO Protocol 2.0", | ||
@@ -32,13 +32,13 @@ "homepage": "https://xyo.network", | ||
"dependencies": { | ||
"@xylabs/assert": "^4.0.2", | ||
"@xylabs/error": "^4.0.2", | ||
"@xylabs/forget": "^4.0.2", | ||
"@xylabs/object": "^4.0.2", | ||
"@xylabs/promise": "^4.0.2" | ||
"@xylabs/assert": "^4.0.3", | ||
"@xylabs/error": "^4.0.3", | ||
"@xylabs/forget": "^4.0.3", | ||
"@xylabs/object": "^4.0.3", | ||
"@xylabs/promise": "^4.0.3" | ||
}, | ||
"devDependencies": { | ||
"@xylabs/delay": "^4.0.2", | ||
"@xylabs/ts-scripts-yarn3": "^4.0.0", | ||
"@xylabs/tsconfig": "^4.0.0", | ||
"@xylabs/tsconfig-jest": "^4.0.0", | ||
"@xylabs/delay": "^4.0.3", | ||
"@xylabs/ts-scripts-yarn3": "^4.0.7", | ||
"@xylabs/tsconfig": "^4.0.7", | ||
"@xylabs/tsconfig-jest": "^4.0.7", | ||
"typescript": "^5.5.4" | ||
@@ -45,0 +45,0 @@ }, |
@@ -7,3 +7,5 @@ import { assertEx } from '@xylabs/assert' | ||
import type { EventAnyListener, EventArgs, EventData, EventFunctions, EventListener, EventName } from '../model/index.ts' | ||
import type { | ||
EventAnyListener, EventArgs, EventData, EventFunctions, EventListener, EventName, | ||
} from '../model/index.ts' | ||
@@ -13,3 +15,4 @@ /** | ||
To enable this feature set the `DEBUG` environment variable to `emittery` or `*`. Additionally, you can set the static `isDebugEnabled` variable to true on the Emittery class, or `myEmitter.debug.enabled` on an instance of it for debugging a single instance. | ||
To enable this feature set the `DEBUG` environment variable to `emittery` or `*`. Additionally, you can set the static `isDebugEnabled` variable to true | ||
on the Emittery class, or `myEmitter.debug.enabled` on an instance of it for debugging a single instance. | ||
@@ -16,0 +19,0 @@ See API for more information on how debugging works. |
@@ -5,5 +5,3 @@ import type { XyTsupConfig } from '@xylabs/ts-scripts-yarn3' | ||
browser: {}, | ||
neutral: { | ||
src: true, | ||
}, | ||
neutral: { src: true }, | ||
node: {}, | ||
@@ -10,0 +8,0 @@ }, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
68358
22
741
Updated@xylabs/assert@^4.0.3
Updated@xylabs/error@^4.0.3
Updated@xylabs/forget@^4.0.3
Updated@xylabs/object@^4.0.3
Updated@xylabs/promise@^4.0.3