can-symbol
Version:
Well known symbols used to detail how to operate on different objects
33 lines (27 loc) • 936 B
Markdown
*))} can-symbol/symbols/offEmit can.offEmit
can-symbol/symbols/observe
Defines how observables can stop listening to the object's value being emitted.
`@ .offEmit( handler(newValue) )`
The `@@@ .offEmit` symbol points to a function that unregisters
`handler` from being called when the object's value
is emitted.
```js
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);
}
```
{*} any object with a mutable value
{function(this:*, *)} handler(newValue) The handler was previously added with [can-symbol/symbols/onEmit `@ .onEmit`].
{function(function(