class Event()

A structure for events fired in various parts of the toolkit.

  • name (string) – the event’s name.
  • data (string) – the event’s data. Optional.
class Event()

Lightweight wrapper around EventEmitter() for working better with Q promises and the toolkit’s Event() objects.


Emits the given event and returns a promise that will be fulfilled once each listener is done. This allows listeners to return promises.

  • event (Event) – the event to emit.
static setup()

Shortcut for emitting a setup event for the instance (since this is done quite often). See SetupEvent().

static teardown()

Shortcut for emitting a teardown event for the instance. See TeardownEvent().


Returns a promise that will be fulfilled once the event has been emitted. Since a promise can only be fulfilled once, the event listener is removed after the event is emitted. Useful for testing events.

  • event_name (string) – the event to listen for.

Removes all event listeners, with the following exception: listeners for TeardownEvent()s get rebound using Eventable.once(), regardless of whether they were orginally bound using Eventable.on() or Eventable.once(). This allows us to remove all event listeners for instances of Eventable(), while still allowing other entities to know when the teardown of the entity has completed.

Not that it is up to the caller to emit the TeardownEvent() to clear the listeners.

class SetupEvent(instance)

Emitted when an instance of something has been constructed.

  • instance (object) – the constructed instance.
class TeardownEvent(instance)

Emitted when an instance of something has completed the tasks it needs to complete before it can be safely disposed of.

  • instance (object) – the instance.