Class bbq.lang.Watchable
Defined in: Watchable.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Method Attributes | Method Name and Description |
---|---|
deRegisterListener(type, callback)
|
|
<static> |
bbq.lang.Watchable.notifyGlobalListeners()
Notifies global listeners.
|
notifyListener(type, key, args)
Calls the passed callback and deregisters it if it's a one time listener.
|
|
notifyListeners(type, args)
Notifies this object's listeners of an event.
|
|
<static> |
bbq.lang.Watchable.registerGlobalListener(type, callback)
Allows us to register for any type of callback called on any object
|
registerListener(type, callback)
|
|
registerOneTimeListener(type, callback)
Similar to Watchable.registerListener except the callback will only be called once
|
Method Detail
deRegisterListener(type, callback)
Name | Type | Comment |
---|---|---|
type | {String} | |
callback | {Function} |
<static> bbq.lang.Watchable.notifyGlobalListeners()
Notifies global listeners.
notifyListener(type, key, args)
Calls the passed callback and deregisters it if it's a one time listener.
Name | Type | Comment |
---|---|---|
type | {String} | The event type |
key | {String} | The callback key |
args | {Array} | Arguments to pass to the callback |
notifyListeners(type, args)
Notifies this object's listeners of an event.
watchable.registerListener("myEvent", function() {
alert("hello");
});
watchable.notifyListeners("myEvent");
// alerts "hello"
By default the watchable is passed as the first argument to the callback function. If you wish to pass extra arguments, do the following:
watchable.registerListener("myEvent", function(theWatchable, someArg) {
alert(someArg);
});
watchable.notifyListeners("myEvent", "bob");
// alerts "bob"
Name | Type | Comment |
---|---|---|
type | {String} | |
args | {...} |
<static> bbq.lang.Watchable.registerGlobalListener(type, callback)
Allows us to register for any type of callback called on any object
Name | Type | Comment |
---|---|---|
type | {String} | |
callback | {Function} |
registerListener(type, callback)
this._dropDown.registerListener("onchange", this._subTypeChanged.bind(this));
Name | Type | Comment |
---|---|---|
type | {String} | |
callback | {Function} |
registerOneTimeListener(type, callback)
Similar to Watchable.registerListener except the callback will only be called once
this._dropDown.registerOneTimeListener("onchange", this._subTypeChanged.bind(this));
Name | Type | Comment |
---|---|---|
type | {String} | |
callback | {Function} |