can.offEmit
Defines how observables can stop listening to the object's value being emitted.
@@can.offEmit( handler(newValue) )
The @@can.offEmit
symbol points to a function that unregisters
handler
from being called when the object's value
is emitted.
const 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.offEmit")] = 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.onEmit
.