can-symbol
Version:
Well known symbols used to detail how to operate on different objects
29 lines (22 loc) • 896 B
Markdown
-symbol/symbols/getValue can.getValue
can-symbol/symbols/get-set
Defines a function that returns the object's current value when called.
`@ .getValue()`
The `@@@ .getValue` symbol points to a function that returns the context object's value. Value may mean different
things in different contexts; e.g. a `can-compute`'s value is the value stored internally to the compute, while an observable object's value may be a non-observable, serialized representation of its properties.
```
var internalValue = undefined
export var foo = function(val) {
if(val) {
internalValue = val;
} else {
return internalValue;
}
};
// Get the internal value as the representative value
foo[canSymbol.for('can.getValue')] = function() {
return internalValue;
}
```
{*} anything that can be resolved to a value
{*} any value
{function()} can