Home Reference Source
import EventHandler from 'yjs/src/Util/EventHandler.js'
public class | source

EventHandler

General event handler implementation.

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public

Method Summary

Public Methods
public

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

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

public

Removes all event listeners.

public

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:

NameTypeAttributeDescription
f Function

The event handler.

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

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

Params:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
f Function

The event handler that was added with EventHandler#addEventListener