can.offValue
Defines how observables can stop listening to the object's value changing.
@@can.offValue( handler(newValue) )
The @@can.offValue
symbol points to a function that unregisters
handler
from being called when the object's value
changes.
var obj = function(value) {
if(arguments.length >= 1) {
obj.currentValue = value;
obj.handlers.forEach(function(handler){
handler.call(obj, value);
});
} else {
return obj.currentValue;
}
};
obj[canSymbol.for("can.offValue")] = function(handler){
if(!obj.handlers) {
obj.handlers = [];
}
obj.handlers.splice(obj.handlers.indexOf(handler), 1);
}
Parameters
- handler
{function(newValue)}
:The handler was previously added with
@@can.onValue
.