events

package
v0.0.0-...-372f1f6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2017 License: MIT Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Emitter

type Emitter struct {
	*js.Object

	// emitter.emit(eventName[, ...args])#
	//
	// Added in: v0.1.26
	// Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments to each.
	//
	// Returns true if the event had listeners, false otherwise.
	Emit func(eventName string, args ...interface{}) bool `js:"emit"`

	// emitter.eventNames()#
	//
	// Added in: v6.0.0
	// Returns an array listing the events for which the emitter has registered listeners. The values in the array will be strings or Symbols.
	//
	// const Emitter = require('events');
	// const myEE = new Emitter();
	// myEE.on('foo', () => {});
	// myEE.on('bar', () => {});
	//
	// const sym = Symbol('symbol');
	// myEE.on(sym, () => {});
	//
	// console.log(myEE.eventNames());
	// // Prints: [ 'foo', 'bar', Symbol(symbol) ]
	EventNames func() []string `js:"eventNames"`

	// Added in: v1.0.0
	// Returns the current max listener value for the Emitter which is either set by emitter.setMaxListeners(n) or defaults to Emitter.defaultMaxListeners.
	//
	// emitter.listenerCount(eventName)#
	LinstenerCount func(eventName string) int `js:"listenerCount"`

	// emitter.removeAllListeners([eventName])#
	//
	// Added in: v0.1.26
	// Removes all listeners, or those of the specified eventName.
	//
	// Note that it is bad practice to remove listeners added elsewhere in the code, particularly when the Emitter instance was created by some other component or module (e.g. sockets or file streams).
	//
	// Returns a reference to the Emitter, so that calls can be chained.
	RemoveAllListener func(eventName ...string) `js:"removeAllListeners"`

	// Returns a reference to the Emitter, so that calls can be chained.
	PreventDefault func() `js:"preventDefault"`
	// contains filtered or unexported fields
}

func New

func New(obj ...*js.Object) *Emitter

func (*Emitter) On

func (e *Emitter) On(eventName string, listener func(args ...*js.Object)) *Emitter

On is a simplified version of OnEvent, using no this

func (*Emitter) OnEvent

func (e *Emitter) OnEvent(eventName string, listener Listener) *Emitter

OnEvent wraps Emitter.on with *Emitter as the first arguments(this in JS)

func (*Emitter) Once

func (e *Emitter) Once(eventName string, listener interface{}) *Emitter

Once is a simplified version of OnEvent, using no this

func (*Emitter) OnceEvent

func (e *Emitter) OnceEvent(eventName string, listener Listener) *Emitter

OnceEvent wraps once with `this` support

type Listener

type Listener func(em *Emitter, args ...*js.Object)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL