with
Creates an observable value from an initial value.
value.with( initialValue )
Creates an observable value can be read and written with the value
property.
It can observed using can-reflect.
import {value} from "can";
const number = value.with("one");
console.log( number.value ); //-> "one"
number.value = "two";
console.log( number.value ); //-> "two"
const handler = function(newValue) {
console.log( newValue ); //-> "three"
};
canReflect.onValue(number, handler);
number.value = "three";
canReflect.offValue(number, handler);
Parameters
- initialValue
{*}
:The initial value of the observable.