@quilted/events
Advanced tools
Comparing version 0.1.1 to 0.1.2
import type { AbortBehavior } from './abort'; | ||
export declare type EmitterEventType = string | symbol; | ||
export declare type EmitterHandler<T = unknown> = (event: T) => void; | ||
export interface Emitter<Events extends Record<EmitterEventType, unknown>> { | ||
export interface Emitter<Events = {}> { | ||
on<Event extends keyof Events>(type: Event, handler: EmitterHandler<Events[Event]>, options?: { | ||
@@ -28,3 +27,3 @@ once?: boolean; | ||
} | ||
export declare function createEmitter<Events extends Record<EmitterEventType, unknown>>(): Emitter<Events>; | ||
export declare function createEmitter<Events = {}>(): Emitter<Events>; | ||
//# sourceMappingURL=emitter.d.ts.map |
@@ -6,4 +6,4 @@ export { on } from './on'; | ||
export { createEmitter } from './emitter'; | ||
export type { Emitter, EmitterHandler, EmitterEventType } from './emitter'; | ||
export type { Emitter, EmitterHandler } from './emitter'; | ||
export type { EventTarget, EventTargetOn, EventTargetAddEventListener, EventTargetFunction, } from './types'; | ||
//# sourceMappingURL=index.d.ts.map |
# @quilted/events | ||
## 0.1.2 | ||
### Patch Changes | ||
- [`f88502ca`](https://github.com/lemonmade/quilt/commit/f88502ca8c969d0da0991523cb1326c9fd6d2203) Thanks [@lemonmade](https://github.com/lemonmade)! - Fix some events types and exports | ||
## 0.1.1 | ||
@@ -4,0 +10,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"type": "module", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"license": "MIT", | ||
@@ -8,0 +8,0 @@ "engines": { |
@@ -5,6 +5,6 @@ import {on as onEvent} from './on'; | ||
export type EmitterEventType = string | symbol; | ||
export type EmitterHandler<T = unknown> = (event: T) => void; | ||
export interface Emitter<Events extends Record<EmitterEventType, unknown>> { | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
export interface Emitter<Events = {}> { | ||
on<Event extends keyof Events>( | ||
@@ -36,5 +36,4 @@ type: Event, | ||
export function createEmitter< | ||
Events extends Record<EmitterEventType, unknown>, | ||
>(): Emitter<Events> { | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
export function createEmitter<Events = {}>(): Emitter<Events> { | ||
const handlerMap = new Map<keyof Events, Set<any>>(); | ||
@@ -75,6 +74,6 @@ | ||
let handlers = handlerMap.get(event); | ||
const signalAbort = new AbortController(); | ||
const signalAbort = signal && new AbortController(); | ||
const remove = () => { | ||
signalAbort.abort(); | ||
signalAbort?.abort(); | ||
handlers!.delete(normalizedHandler); | ||
@@ -98,4 +97,4 @@ }; | ||
signal?.addEventListener('abort', remove, {signal: signalAbort.signal}); | ||
signal?.addEventListener('abort', remove, {signal: signalAbort!.signal}); | ||
} | ||
} |
@@ -6,3 +6,3 @@ export {on} from './on'; | ||
export {createEmitter} from './emitter'; | ||
export type {Emitter, EmitterHandler, EmitterEventType} from './emitter'; | ||
export type {Emitter, EmitterHandler} from './emitter'; | ||
export type { | ||
@@ -9,0 +9,0 @@ EventTarget, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
95933