Class bbq.lang.Watchable

Defined in: Watchable.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Method Summary
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

Constructor Detail

bbq.lang.Watchable()

Method Detail

deRegisterListener(type, callback)

Parameters:
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.
Parameters:
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"
Parameters:
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
Parameters:
Name Type Comment
type {String}
callback {Function}

registerListener(type, callback)


this._dropDown.registerListener("onchange", this._subTypeChanged.bind(this));
Parameters:
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));
Parameters:
Name Type Comment
type {String}
callback {Function}