springroll.PropertyDispatcher Class

Event dispatcher with ability to detect whenever a property is changed.

Constructor

springroll.PropertyDispatcher

()

add

(
  • prop
  • [value=null]
  • [readOnly=false]
)
PropertyDispatcher

Defined in add:73

Add a new property to allow deteching

Parameters:

  • prop String

    The property name

  • [value=null] Mixed optional

    The default value

  • [readOnly=false] Boolean optional

    If the property is readonly

Returns:

PropertyDispatcher:

The instance for chaining

destroy

()

Inherited from springroll.EventDispatcher but overwritten in destroy:133

Clean-up all references, don't use after this

get

(
  • prop
)
Mixed
private

Defined in get:54

Generic setter for an option

Parameters:

Returns:

Mixed:

The value of the option

has

(
  • name
  • [callback]
)
Boolean

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.

off

(
  • name
  • callback
)
EventDispatcher

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

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

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.

readOnly

(
  • prop
)
springroll.PropertyDispatcher
deprecated

Defined in readOnly:71

Deprecated: since version 0.4.0

Turn on read-only for properties

Parameters:

  • prop String multiple

    The property or properties to make readonly

Returns:

springroll.PropertyDispatcher:

The instance for chaining

respond

(
  • name
  • responder
)
PropertyDispatcher

Defined in respond:108

Whenever a property is get a responder is called

Parameters:

  • name String

    The property name

  • responder Function

    Function to call when getting property

Returns:

PropertyDispatcher:

The instance for chaining

set

(
  • prop
  • value
)
private

Defined in set:32

Generic setter for an option

Parameters:

  • prop String

    The property name

  • value Mixed

    The value to set

trigger

(
  • type
  • arguments
)

Dispatch an event

Parameters:

  • type String

    The type of event to trigger

  • arguments

    Additional parameters for the listener functions.

type

(
  • value
)
String
private

Return type of the value.

Parameters:

  • value

Returns:

String:

The type

_destroyed

Boolean protected

If the dispatcher is destroyed

_listeners

Object private

The collection of listeners

_properties

Object private

Defined in _properties:20

The map of property values to store

destroyed

Boolean

If the dispatcher is destroyed