-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.value functions should not be observable #162
Comments
http://jsbin.com/yafajal/edit?html,js,output Also related ... we should check the number of dependencies in the observation. |
Also, we can probably avoid here: canjs/can-reflect#2 |
var DriversListVM = can.DefineMap.extend({
drivers: {
value: function(){
return new can.DefineList([
{ title: "Dr.", first: "Cosmo", last: "Kramer", licensePlate: "A$$M^N" },
{ title: "Ms.", first: "Elaine", last: "Benes", licensePlate: "621433" }
])
}
},
selected: {
value: false
},
select: function(driver){
this.selected = driver;
}
}) var func = function(){};
func = Observation.ignore(func);
func(); |
return function(newVal) {
if( this._inSetup ) {
setData.call(this, newVal);
} else {
var current = getCurrent.call(this);
if (newVal !== current) {
setData.call(this, newVal);
canEvent.dispatch.call(this, {
type: prop,
target: this
}, [newVal, current]);
}
}
} |
https://github.com/canjs/can-define/blob/master/can-define.js#L178 getInitialValue = Observation.ignore( make.get.defaultValue(prop, definition, typeConvert, eventsSetter) ); |
#162 .value functions should not be observable.
It turns out we couldn't avoid |
If they are observable and invoked as part of a template, big problems can happen.
The solution is just to make sure
Observation.add should not be called if
this.__inSetup
is true: https://github.com/canjs/can-construct/blob/master/can-construct.js#L280We should wrap
value
withObservation.ignore
.The text was updated successfully, but these errors were encountered: