rivets icon indicating copy to clipboard operation
rivets copied to clipboard

Computed properties don't seem to resubscribe when the model is updated

Open stephenhand opened this issue 12 years ago • 5 comments

I had an issue where certain parts of my view stopped reacting to model updates because the computed bindings they depended on didn't unsubscribe from old models and resubscribe to new ones when the model structure updated. in the same way other bindings did.

I resolved the issue by modifying the Binding.update function. I will provide my changes in a pull request in case they are useful.

stephenhand avatar Sep 26 '13 21:09 stephenhand

I believe I'm facing the same problem. Here's a fiddle: http://jsfiddle.net/ZRHdA/3/ (rivets.js is loaded from the HEAD of master at rawgithub.com)

@mikeric any chance this issue will be addressed in the near future?

ento avatar Feb 07 '14 10:02 ento

I confirm the bug is still present. I updated the fiddle with the most recent build: http://jsfiddle.net/ZRHdA/4/

blikblum avatar Feb 07 '16 18:02 blikblum

I think this bug would not appear if we replace computed properties by functions calling like i described in #571 :wink:

jccazeaux avatar Feb 07 '16 19:02 jccazeaux

Here is a jsfiddle of what I have in mind http://jsfiddle.net/jccazeaux/b64cw9qy/ Code for this feature is on this branch

jccazeaux avatar Feb 07 '16 21:02 jccazeaux

This is definitely an issue.

I spent some time debugging and was only ever able to reproduce when putting computed on the prototype. This makes me think it could be related to: https://github.com/mikeric/rivets/issues/572

There are allot of weird github issues I can cite with no resolution around how rivets handles methods and properties on prototypes. Will subsequently update this post and cite them if I have a moment tomorrow.

@jccazeaux That call formatter is cool. Would definitely be useful feature.

The work that @stephenhand did some years back seems to be a big change for a small issue.

There is some interesting discussion here around such things: https://github.com/mikeric/rivets/pull/417

I wonder what the implications of modifying this line in sightglass as https://github.com/mikeric/sightglass/blob/master/index.js#L128 as @jccazeaux has pointed out.

Duder-onomy avatar Feb 08 '16 08:02 Duder-onomy