Event.Target

EventTarget provides the implementation for any object to publish, subscribe and fire to custom events, and also allows other EventTargets to target the object with events sourced from the other object. EventTarget is designed to be used with S.augment to allow events to be listened to and fired by name. This makes it possible for implementing code to subscribe to an event that either has not been created yet, or will not be created at all.

defined in: target.js

Namespace

Methods

  • Event.Target. addTarget (target) <static> Registers another EventTarget as a bubble target.
  • Event.Target. detach (type, fn, scope) <static> Detach one or more listeners the from the specified event
  • Event.Target. fire (type, eventData) <static> Fire a custom event by name.
  • Event.Target. on (type, fn, scope) <static> Subscribe a callback function to a custom event fired by this object or from an object that bubbles its events to this object.
  • Event.Target. publish (type, cfg) <static> Creates a new custom event of the specified type
  • Event.Target. removeTarget (target) <static> Removes a bubble target

Namespace Detail

  • Event.Target
    EventTarget provides the implementation for any object to publish, subscribe and fire to custom events, and also allows other EventTargets to target the object with events sourced from the other object. EventTarget is designed to be used with S.augment to allow events to be listened to and fired by name. This makes it possible for implementing code to subscribe to an event that either has not been created yet, or will not be created at all.

Methods Detail

  • Event.Target. addTarget (target) <static> view source
    Registers another EventTarget as a bubble target.
    Parameters
    •   target {Event.Target} Another EventTarget instance to add
  • Event.Target. detach (type, fn, scope) <static> view source
    Detach one or more listeners the from the specified event
    Parameters
    •   type {String} The name of the event
    • [ fn ] {Function} The subscribed function to unsubscribe. if not supplied, all subscribers will be removed.
    • [ scope ] {Object} The custom object passed to subscribe.
  • Event.Target. fire (type, eventData) <static> view source
    Fire a custom event by name. The callback functions will be executed from the context specified when the event was created, and the Event.Object created will be mixed with eventData
    Parameters
    •   type {String} The type of the event
    • [ eventData ] {Object} The data will be mixed with Event.Object created
    Returns
    • {Boolean|*} If any listen returns false, then the returned value is false. else return the last listener's returned value
  • Event.Target. on (type, fn, scope) <static> view source
    Subscribe a callback function to a custom event fired by this object or from an object that bubbles its events to this object.
    Parameters
    •   type {String} The name of the event
    •   fn {Function} The callback to execute in response to the event
    • [ scope ] {Object} this object in callback
  • Event.Target. publish (type, cfg) <static> view source
    Creates a new custom event of the specified type
    Parameters
    •   type {String} The type of the event
    •   cfg {Object} Config params
    • [ cfg.bubbles = false ] {Boolean} whether or not this event bubbles
  • Event.Target. removeTarget (target) <static> view source
    Removes a bubble target
    Parameters
    •   target {Event.Target} Another EventTarget instance to remove
blog comments powered by Disqus
Top