Class Index | File Index

Classes


Function Namespace Pot.Signal.attach


Defined in: <potlite.js>.

Function Namespace Summary
Constructor Attributes Constructor Name and Description
 
Pot.Signal.attach(object, signalName, callback, (useCapture), (once))
Attaches a signal to a slot, and return a handler object as a unique identifier that can be used to detach that signal.
Method Summary
Method Attributes Method Name and Description
<static>  
Pot.Signal.attach.once(object, signalName, callback, (useCapture))
Similar to attach*(), but detaches the signal handler automatically once it has fired.
Function Namespace Detail
Pot.Signal.attach(object, signalName, callback, (useCapture), (once))
Attaches a signal to a slot, and return a handler object as a unique identifier that can be used to detach that signal.
  // Usage like addEventListener/removeEventListener.
  // Will get to a DOM element by document.getElementById if the
  //   first argument passed as a string.
  var handler = attach('#foo', 'click', function(ev) {...});
  //
  // Release the signal(Event).
  detach(handler);
  // Example code of signal for Object usage.
  var MyObj = {};
  // Register your own signal.
  var handler = attach(MyObj, 'clear-data', function() {
    // To initialize the properties etc.
    MyObj.data = null;
    MyObj.time = null;
  });
  attach(window, 'load', function() {
    // Send a signal to initialize.
    signal(MyObj, 'clear-data');
    // Also set to clear when you press the reset button.
    attach('#reset', 'click', function() {
      signal(MyObj, 'clear-data');
    });
    // Existing processing etc.
    myLoadProcess();
    //...
  });
Parameters:
{Object|Function|String} object
The object that be target of the signal. If passed in a string then will be a HTML element by document.getElementById.
{String|Array} signalName
`signalName` is a string that represents a signal name. If `object` is a DOM object then it can be specify one of the 'onxxx' native events. That case 'on' prefix is optionally.
{Function} callback
An action to take when the signal is triggered.
{Boolean} (useCapture)
(Optional) `useCapture` will passed its 3rd argument to addEventListener if environment is available it on DOM.
{Boolean} (once)
(Optional) Only internal usage.
Returns:
{Object|Array} Return an instance of Pot.Signal.Handler object as a unique identifier that can be used to detach that signal.
Method Detail
<static> {Function} Pot.Signal.attach.once(object, signalName, callback, (useCapture))
Similar to attach*(), but detaches the signal handler automatically once it has fired.
  attach.once(document.body, 'click', function() {
    alert('This message will show only once.');
  });
Parameters:
{Object|Function|String} object
The object that be target of the signal. If passed in a string then will be a HTML element by document.getElementById.
{String} signalName
`signalName` is a string that represents a signal name. If `object` is a DOM object then it can be specify one of the 'onxxx' native events. That case 'on' prefix is optionally.
{Function} callback
An action to take when the signal is triggered.
{Boolean} (useCapture)
(Optional) `useCapture` will passed its 3rd argument to addEventListener if environment is available it on DOM.
Returns:
{Object} Return an instance of Pot.Signal.Handler object as a unique identifier that can be used to detach that signal.

Documentation generated by JsDoc Toolkit 2.4.0 on Fri Sep 21 2012 19:35:45 GMT+0900 (JST)