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

Observer

Indirect Subclass:

MediaElement, MultiCanvas

Observer class

Constructor Summary

Public Constructor
public

Instantiate Observer

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

un(event: string, fn: function)

Remove an event handler.

public

unAll()

Remove all event handlers.

Public Constructors

public constructor() source

Instantiate Observer

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

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

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.