springroll.EventDispatcher Class

Module: Core

The EventDispatcher mirrors the functionality of AS3 and EaselJS's EventDispatcher, but is more robust in terms of inputs for the on() and off() methods.

Constructor

springroll.EventDispatcher

()

Methods

destroy

()

Defined in destroy:249

Destroy and don't use after this

has

(
  • name
  • [callback]
)
Boolean

Defined in has:230

Checks if the EventDispatcher has a specific listener or any listener for a given event.

Parameters:

  • name String

    The name of the single event type to check for

  • [callback] Function optional

    The listener function to check for. If omitted, checks for any listener.

Returns:

Boolean:

If the EventDispatcher has the specified listener.

mixIn

()
deprecated static

Defined in mixIn:37

Deprecated: since version 0.4.0

off

(
  • name
  • callback
)
EventDispatcher

Defined in off:172

Remove the event listener

Parameters:

  • name String*

    The type of event string separated by spaces, if no name is specifed remove all listeners.

  • callback Function | Array*

    The listener function or collection of callback functions

Returns:

EventDispatcher:

Return this EventDispatcher for chaining calls.

on

(
  • name
  • callback
  • [priority=0]
)
EventDispatcher

Defined in on:98

Add an event listener. The parameters for the listener functions depend on the event.

Parameters:

  • name String | Object

    The type of event (can be multiple events separated by spaces), or a map of events to handlers

  • callback Function | Array*

    The callback function when event is fired or an array of callbacks.

  • [priority=0] Int optional

    The priority of the event listener. Higher numbers are handled first.

Returns:

EventDispatcher:

Return this EventDispatcher for chaining calls.

once

(
  • name
  • callback
  • [priority=0]
)
EventDispatcher

Defined in once:83

Add an event listener but only handle it one time.

Parameters:

  • name String | Object

    The type of event (can be multiple events separated by spaces), or a map of events to handlers

  • callback Function | Array*

    The callback function when event is fired or an array of callbacks.

  • [priority=0] Int optional

    The priority of the event listener. Higher numbers are handled first.

Returns:

EventDispatcher:

Return this EventDispatcher for chaining calls.

trigger

(
  • type
  • arguments
)

Defined in trigger:48

Dispatch an event

Parameters:

  • type String

    The type of event to trigger

  • arguments

    Additional parameters for the listener functions.

type

(
  • value
)
String
private

Defined in type:259

Return type of the value.

Parameters:

  • value

Returns:

String:

The type

_destroyed

Boolean protected

Defined in _destroyed:24

If the dispatcher is destroyed

_listeners

Object private

Defined in _listeners:17

The collection of listeners

destroyed

Boolean

Defined in destroyed:35

If the dispatcher is destroyed