    import EventHandler from 'yjs/src/Util/EventHandler.js'

public class | source

# EventHandler

General event handler implementation.

## Constructor Summary

Public Constructor
public | constructor () |

## Member Summary

Public Members
public | eventListeners : *[] |

## Method Summary

Public Methods
public | addEventListener (f: Function) Adds an event listener that is called when EventHandler#callEventListeners is called. |
public | callEventListeners (transaction: Transaction, event: YEvent) Call all event listeners that were added via EventHandler#addEventListener. |
public | destroy () To prevent memory leaks, call this method when the eventListeners won't be used anymore. |
public | removeAllEventListeners () Removes all event listeners. |
public | removeEventListener (f: Function) Removes an event listener. |

## Public Constructors

### public constructor() source

## Public Members

### public eventListeners: *[] source

## Public Methods

### public addEventListener(f: Function) source

Adds an event listener that is called when EventHandler#callEventListeners is called.

#### Params:

Name | Type | Attribute | Description
f | Function |  | The event handler.

### public callEventListeners(transaction: Transaction, event: YEvent) source

Call all event listeners that were added via EventHandler#addEventListener.

#### Params:

Name | Type | Attribute | Description
transaction | Transaction |  | The transaction object // TODO: do we need this?
event | YEvent |  | An event object that describes the change on a type.

### public destroy() source

To prevent memory leaks, call this method when the eventListeners won't be used anymore.

### public removeAllEventListeners() source

Removes all event listeners.

### public removeEventListener(f: Function) source

Removes an event listener.

#### Params:

Name | Type | Attribute | Description
f | Function |  | The event handler that was added with EventHandler#addEventListener