Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(EventDispatcher): expose protected listeners #1375

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions types/three/src/core/EventDispatcher.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,27 @@ export type EventListener<TEventData, TEventType extends string, TTarget> = (
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/core/EventDispatcher.js | Source}
*/
export class EventDispatcher<TEventMap extends {} = {}> {
/**
* Maps event types to the list of their listeners.
* Only initialized when a listener is added.
* Event type entries are created when their first listener is added.
*
* @example
* ```typescript
* type MyDisp = EventDispatcher<{ a: { b: number }, c: { d: string } }>;
* const disp = new MyDisp();
* // typeof disp._listeners ==
* // | undefined
* // | {
* // a?: EventListener<{ b: number }, 'a', this>[],
* // c?: EventListener<{ d: string }, 'c', this>[],
* // };
* ```
*/
protected _listeners?: {
[Type in Extract<keyof TEventMap, string>]?: EventListener<TEventMap[Type], Type, this>[];
};

/**
* Creates {@link THREE.EventDispatcher | EventDispatcher} object.
*/
Expand Down
Loading