Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

d3-dispatch

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-dispatch

Register named callbacks and call them with arguments.

  • 0.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.9M
increased by3.48%
Maintainers
1
Weekly downloads
 
Created

What is d3-dispatch?

The d3-dispatch module provides a simple mechanism for registering named callbacks and dispatching events to those callbacks. It is part of the D3.js library and is useful for managing events in a modular and decoupled way.

What are d3-dispatch's main functionalities?

Creating a Dispatcher

This feature allows you to create a dispatcher with named events. In this example, a dispatcher is created with two events: 'start' and 'end'.

const d3 = require('d3-dispatch');
const dispatch = d3.dispatch('start', 'end');

Registering Callbacks

This feature allows you to register callbacks for the named events. Here, two callbacks are registered: one for the 'start' event and one for the 'end' event.

dispatch.on('start', () => console.log('Started!'));
dispatch.on('end', () => console.log('Ended!'));

Dispatching Events

This feature allows you to dispatch events, triggering the registered callbacks. In this example, the 'start' and 'end' events are dispatched, causing the respective callbacks to be executed.

dispatch.call('start');
dispatch.call('end');

Passing Arguments to Callbacks

This feature allows you to pass arguments to the callbacks when dispatching events. Here, a message is passed to the 'start' event callback.

dispatch.on('start', (message) => console.log('Started:', message));
dispatch.call('start', null, 'Initialization complete');

Other packages similar to d3-dispatch

Keywords

FAQs

Package last updated on 04 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc