@types/d3-dispatch
- Version 3.0.7
- Published
- 7.62 kB
- No dependencies
- MIT license
Install
npm i @types/d3-dispatch
yarn add @types/d3-dispatch
pnpm add @types/d3-dispatch
Overview
TypeScript definitions for d3-dispatch
Index
Variables
Functions
Interfaces
Namespaces
Variables
variable any
const any: any;
variable EventMap
const EventMap: any;
variable EventNames
const EventNames: any;
variable keyof
const keyof: any;
Functions
function dispatch
dispatch: < This extends object, EventMap extends Record<EventNames, any[]>>() => any;
Creates a new dispatch for the specified event types. Each type is a string, such as "start" or "end".
Parameter types
The event types.
Throws
"illegal type" on empty string or duplicated event types.
Interfaces
interface Dispatch
interface Dispatch< This extends object, EventMap extends Dispatch.GenericEventMap = Dispatch.GenericEventMap> {}
method apply
apply: <U extends keyof EventMap>( type: U, that?: This, args?: EventMap[U]) => void;
Like
function.apply
, invokes each registered callback for the specified type, passing the callback the specified arguments, withthat
as thethis
context.Parameter type
A specified event type.
Parameter that
The
this
context for the callback.Parameter args
Additional arguments to be passed to the callback.
Throws
"unknown type" on unknown event type.
method call
call: <U extends keyof EventMap>( type: U, that?: This, ...args: EventMap[U]) => void;
Like
function.call
, invokes each registered callback for the specified type, passing the callback the specified arguments, withthat
as thethis
context. See dispatch.apply for more information.Parameter type
A specified event type.
Parameter that
The
this
context for the callback.Parameter args
Additional arguments to be passed to the callback.
Throws
"unknown type" on unknown event type.
method copy
copy: () => Dispatch<This, EventMap>;
Returns a copy of this dispatch object. Changes to this dispatch do not affect the returned copy and vice versa.
method on
on: { <Source extends string>( typenames: Source ): Dispatch.ExtractEventNames<Source> extends keyof EventMap ? ( this: This, ...args: MapUnion<Dispatch.ExtractEventNames<Source>, EventMap> ) => void : never; <Source extends string>( typenames: Source, callback: Dispatch.ExtractEventNames<Source> extends keyof EventMap ? ( this: This, ...args: MapUnion<Dispatch.ExtractEventNames<Source>, EventMap> ) => void : never ): this;};
Returns the callback for the specified typenames, if any. If multiple typenames are specified, the first matching callback is returned.
Adds or removes the callback for the specified typenames. If a callback function is specified, it is registered for the specified (fully-qualified) typenames. If a callback was already registered for the given typenames, the existing callback is removed before the new callback is added. The specified typenames is a string, such as start or end.foo. The type may be optionally followed by a period (.) and a name; the optional name allows multiple callbacks to be registered to receive events of the same type, such as start.foo and start.bar. To specify multiple typenames, separate typenames with spaces, such as start end or start.foo start.bar. To remove all callbacks for a given name foo, say dispatch.on(".foo", null).
Namespaces
namespace Dispatch
namespace Dispatch {}
interface GenericEventMap
interface GenericEventMap {}
defines all the events that can be emitted. Each property is the arguments for that event.
index signature
[eventName: string]: any[];
type ExtractEventNames
type ExtractEventNames<Input extends string> = Input extends '' ? never : Input extends `${infer A} ${infer B}` // multiple events ? ExtractEventNames<A> | ExtractEventNames<B> : Input extends `${infer A}.${string}` // single event with a name ? A : Input;
given a string like
a.1 b c.2
, it returns a union like'a' | 'b' | 'c'
Package Files (1)
Dependencies (0)
No dependencies.
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/d3-dispatch
.
- Markdown[](https://www.jsdocs.io/package/@types/d3-dispatch)
- HTML<a href="https://www.jsdocs.io/package/@types/d3-dispatch"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3625 ms. - Missing or incorrect documentation? Open an issue for this package.