Home Reference Source
import Observer from 'wavesurfer.js/src/util/observer.js'
public class | source

Observer

Observer class

Constructor Summary

Public Constructor
public

Instantiate Observer

Member Summary

Public Members
public

Method Summary

Public Methods
public

fireEvent(event: string, args: ...any)

Manually fire an event

public

Attach a handler function for an event.

public

once(event: string, handler: function): ListenerDescriptor

Attach a handler to an event.

public

Disable firing a list of events by name.

since 4.0.0
public

un(event: string, fn: function)

Remove an event handler.

public

unAll()

Remove all event handlers.

Public Constructors

public constructor() source

Instantiate Observer

Public Members

public handlers: * source

Public Methods

public fireEvent(event: string, args: ...any) source

Manually fire an event

Params:

NameTypeAttributeDescription
event string

The event to fire manually

args ...any

The arguments with which to call the listeners

public on(event: string, fn: function): ListenerDescriptor source

Attach a handler function for an event.

Params:

NameTypeAttributeDescription
event string

Name of the event to listen to

fn function

The callback to trigger when the event is fired

Return:

ListenerDescriptor

The event descriptor

public once(event: string, handler: function): ListenerDescriptor source

Attach a handler to an event. The handler is executed at most once per event type.

Params:

NameTypeAttributeDescription
event string

The event to listen to

handler function

The callback that is only to be called once

Return:

ListenerDescriptor

The event descriptor

public setDisabledEventEmissions(eventNames: string[]) since 4.0.0 source

Disable firing a list of events by name. When specified, event handlers for any event type passed in here will not be called.

Params:

NameTypeAttributeDescription
eventNames string[]

an array of event names to disable emissions for

Example:

// disable seek and interaction events
wavesurfer.setDisabledEventEmissions(['seek', 'interaction']);

public un(event: string, fn: function) source

Remove an event handler.

Params:

NameTypeAttributeDescription
event string

Name of the event the listener that should be removed listens to

fn function

The callback that should be removed

public unAll() source

Remove all event handlers.