can-symbol
Version:
Well known symbols used to detail how to operate on different objects
29 lines (22 loc) • 955 B
Markdown
{function()} can-symbol/symbols/setValue can.setValue
can-symbol/symbols/get-set
Define a function that sets the object's value.
`@.setValue( value )`
The `@@@.setValue` symbol points to a function that sets the current value on the context object. "Value" may mean different
things in different contexts; e.g. setting a [can-compute]'s value updates the value stored internally to the compute, while setting an observable object's value will update all of the same-keyed properties of the object argument.
```
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.setValue')] = function(value) {
internalValue = value;
}
```
{*} anything that can be resolved to a value
{*} value any appropriate value to set on the object