Method: emit

Emit an event by name.
emit (Object eventName, Object || Array args)
  • ObjecteventName The name of the event to emit.
  • Object || Arrayargs The arguments to send to any listening methods. If you are sending multiple arguments, use an array containing each argument.
Returns Number

Emit an Event

// Emit the event named "hello"

Emit an Event With Data Object

// Emit the event named "hello"
myEntity.emit('hello', {moo: true});

Emit an Event With Multiple Data Values

// Emit the event named "hello"
myEntity.emit('hello', [{moo: true}, 'someString']);

Listen for Event Data

// Set a listener to listen for the data (multiple values emitted
// from an event are passed as function arguments)
myEntity.on('hello', function (arg1, arg2) {
    console.log(arg1, arg2);

// Emit the event named "hello"
myEntity.emit('hello', ['data1', 'data2']);

// The console output is:
//  data1, data2
© Copyright 2013 Irrelon Software Limited. All Rights Reserved. UK Registered Company Number: 07522767
Isogenic (ī´sōjen´ik): Adj originating from a common source; possessing the same genetic composition.
Strange Things Happen at the One Two Point