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