can-symbol
Version:
Well known symbols used to detail how to operate on different objects
36 lines (29 loc) • 1.36 kB
Markdown
function(String)} can-symbol/symbols/keyHasDependencies can.keyHasDependencies
can-symbol/symbols/observe
Check if there are any other objects that affect the value of a named property.
`@@can.keyHasDependencies(key)`
The `@@@@can.keyHasDependencies` symbol points to a function that returns `true` if there are any other events or property
changes that will change the value of the property on the context object with key `key`; `false` otherwise.
By convention, if an object implementation distinguishes between unbound objects or values, and those
which are bound without external dependencies (as is the case with [can-map]), `@@@@can.keyHasDependencies` may return
`undefined` for unbound objects instead of `false`.
```
var someOtherObj;
var obj = {
__bindEvents: {
foo: [{
handler: function() {},
reads: [{ object: someOtherObj, key: "bar" }]
}]
}
};
obj[canSymbol.for("can.keyHasDependencies")] = function(key) {
return this.__bindEvents[key] &&
this.__bindEvents[key].filter(function(binding) {
return binding.reads && binding.reads.length > 0;
}).length > 0;
};
```
{MapLike} any map-like object with named properties
{String} key the key to check for dependent bindings
{Boolean} true if there are any other objects that this keyed propertey depends on
{