on Class — svelte Architecture
Architecture documentation for the on class in index.d.ts from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD 8a31f7b9_aa96_cd50_884d_2931612b96b0["on"] 6bd9d090_a582_e05c_669e_d53d4e7245f2["index.d.ts"] 8a31f7b9_aa96_cd50_884d_2931612b96b0 -->|defined in| 6bd9d090_a582_e05c_669e_d53d4e7245f2 cc2a9c85_d16d_78b4_2d1c_d8024c6aab8e["on()"] 8a31f7b9_aa96_cd50_884d_2931612b96b0 -->|method| cc2a9c85_d16d_78b4_2d1c_d8024c6aab8e
Relationship Graph
Source Code
packages/svelte/types/index.d.ts lines 2808–2868
declare module 'svelte/events' {
// Once https://github.com/microsoft/TypeScript/issues/59980 is fixed we can put these overloads into the JSDoc comments of the `on` function
/**
* Attaches an event handler to the window and returns a function that removes the handler. Using this
* rather than `addEventListener` will preserve the correct order relative to handlers added declaratively
* (with attributes like `onclick`), which use event delegation for performance reasons
*/
export function on<Type extends keyof WindowEventMap>(
window: Window,
type: Type,
handler: (this: Window, event: WindowEventMap[Type] & { currentTarget: Window }) => any,
options?: AddEventListenerOptions | undefined
): () => void;
/**
* Attaches an event handler to the document and returns a function that removes the handler. Using this
* rather than `addEventListener` will preserve the correct order relative to handlers added declaratively
* (with attributes like `onclick`), which use event delegation for performance reasons
*/
export function on<Type extends keyof DocumentEventMap>(
document: Document,
type: Type,
handler: (this: Document, event: DocumentEventMap[Type] & { currentTarget: Document }) => any,
options?: AddEventListenerOptions | undefined
): () => void;
/**
* Attaches an event handler to an element and returns a function that removes the handler. Using this
* rather than `addEventListener` will preserve the correct order relative to handlers added declaratively
* (with attributes like `onclick`), which use event delegation for performance reasons
*/
export function on<Element extends HTMLElement, Type extends keyof HTMLElementEventMap>(
element: Element,
type: Type,
handler: (this: Element, event: HTMLElementEventMap[Type] & { currentTarget: Element }) => any,
options?: AddEventListenerOptions | undefined
): () => void;
/**
* Attaches an event handler to an element and returns a function that removes the handler. Using this
* rather than `addEventListener` will preserve the correct order relative to handlers added declaratively
* (with attributes like `onclick`), which use event delegation for performance reasons
*/
export function on<Element extends MediaQueryList, Type extends keyof MediaQueryListEventMap>(
element: Element,
type: Type,
handler: (this: Element, event: MediaQueryListEventMap[Type] & { currentTarget: Element }) => any,
options?: AddEventListenerOptions | undefined
): () => void;
/**
* Attaches an event handler to an element and returns a function that removes the handler. Using this
* rather than `addEventListener` will preserve the correct order relative to handlers added declaratively
* (with attributes like `onclick`), which use event delegation for performance reasons
*/
export function on(
element: EventTarget,
type: string,
handler: EventListener,
options?: AddEventListenerOptions | undefined
): () => void;
export {};
}
Defined In
Source
Frequently Asked Questions
What is the on class?
on is a class in the svelte codebase, defined in packages/svelte/types/index.d.ts.
Where is on defined?
on is defined in packages/svelte/types/index.d.ts at line 2808.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free