createEventDispatcher() — svelte Function Reference
Architecture documentation for the createEventDispatcher() function in index-client.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD 8b5898aa_f3a9_86ef_471f_73e019323c86["createEventDispatcher()"] 717fc8d5_bdb4_4b73_d6c5_c4a367a60cf2["index-client.js"] 8b5898aa_f3a9_86ef_471f_73e019323c86 -->|defined in| 717fc8d5_bdb4_4b73_d6c5_c4a367a60cf2 6f9aee52_ea1e_49b7_4d74_b070e0c04958["create_custom_event()"] 8b5898aa_f3a9_86ef_471f_73e019323c86 -->|calls| 6f9aee52_ea1e_49b7_4d74_b070e0c04958 style 8b5898aa_f3a9_86ef_471f_73e019323c86 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/svelte/src/index-client.js lines 157–185
export function createEventDispatcher() {
const active_component_context = component_context;
if (active_component_context === null) {
e.lifecycle_outside_component('createEventDispatcher');
}
/**
* @param [detail]
* @param [options]
*/
return (type, detail, options) => {
const events = /** @type {Record<string, Function | Function[]>} */ (
active_component_context.s.$$events
)?.[/** @type {string} */ (type)];
if (events) {
const callbacks = is_array(events) ? events.slice() : [events];
// TODO are there situations where events could be dispatched
// in a server (non-DOM) environment?
const event = create_custom_event(/** @type {string} */ (type), detail, options);
for (const fn of callbacks) {
fn.call(active_component_context.x, event);
}
return !event.defaultPrevented;
}
return true;
};
}
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does createEventDispatcher() do?
createEventDispatcher() is a function in the svelte codebase, defined in packages/svelte/src/index-client.js.
Where is createEventDispatcher() defined?
createEventDispatcher() is defined in packages/svelte/src/index-client.js at line 157.
What does createEventDispatcher() call?
createEventDispatcher() calls 1 function(s): create_custom_event.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free