Function Namespace Pot.Signal.attachPropBefore
Defined in: <potlite.js>.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
Pot.Signal.attachPropBefore(object, signalName, callback, (useCapture), (once))
Attaches a signal to a slot on before,
and return a handler object as a unique identifier that
can be used to detach that signal.
|
| Method Attributes | Method Name and Description |
|---|---|
| <static> |
Pot.Signal.attachPropBefore.once(object, signalName, callback, (useCapture))
Similar to attach*(),
but detaches the signal handler automatically once it has fired.
|
Function Namespace Detail
Pot.Signal.attachPropBefore(object, signalName, callback, (useCapture), (once))
Attaches a signal to a slot on before,
and return a handler object as a unique identifier that
can be used to detach that signal.
When method is called, this callback will be triggered.
// Example code for add callback to the
// Object direct like aspect settings.
var MyApp = {
execute : function() {
// Begin something process.
myAppDoit();
}
};
attach('#execute', 'click', function() {
// Execute Application.
MyApp.execute();
});
// Add a logging callback function before execution.
attachPropBefore(MyApp, 'execute', function() {
MyLogger.log('Begin execute');
});
// Add a logging callback function after execution.
attachPropAfter(MyApp, 'execute', function() {
MyLogger.log('End execute');
});
- 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.attachPropBefore.once(object, signalName, callback, (useCapture))
Similar to attach*(),
but detaches the signal handler automatically once it has fired.
attachPropBefore.once(MyObj, 'initialize', 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.