Home / Function/ $on() — svelte Function Reference

$on() — svelte Function Reference

Architecture documentation for the $on() function in legacy-client.js from the svelte codebase.

Entity Profile

Dependency Diagram

graph TD
  886e4199_1a2e_3170_a9a6_cd048c976a0d["$on()"]
  4a6dd8eb_d702_b5bf_74e8_1b0f596492ee["Svelte4Component"]
  886e4199_1a2e_3170_a9a6_cd048c976a0d -->|defined in| 4a6dd8eb_d702_b5bf_74e8_1b0f596492ee
  ea5280ff_3b87_42ee_3823_3570b76a5779["push()"]
  886e4199_1a2e_3170_a9a6_cd048c976a0d -->|calls| ea5280ff_3b87_42ee_3823_3570b76a5779
  style 886e4199_1a2e_3170_a9a6_cd048c976a0d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/legacy/legacy-client.js lines 166–175

	$on(event, callback) {
		this.#events[event] = this.#events[event] || [];

		/** @param {any[]} args */
		const cb = (...args) => callback.call(this, ...args);
		this.#events[event].push(cb);
		return () => {
			this.#events[event] = this.#events[event].filter(/** @param {any} fn */ (fn) => fn !== cb);
		};
	}

Subdomains

Calls

Frequently Asked Questions

What does $on() do?
$on() is a function in the svelte codebase, defined in packages/svelte/src/legacy/legacy-client.js.
Where is $on() defined?
$on() is defined in packages/svelte/src/legacy/legacy-client.js at line 166.
What does $on() call?
$on() calls 1 function(s): push.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free