You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i may be missing something, but it doesn't look like mutators supports dependent fields, right?
is there any good reason against this? if so, would you recommend any other library?
cheers,
daniel
The text was updated successfully, but these errors were encountered:
(@asciidisco has gotten super busy and has asked for folks to help out around here, so maybe I can help implement this. If you're not interested in the issue anymore, feel free to ignore; I still like the idea :)
You're correct, Mutators does not currently support dependency declarations. There are at least a couple of other libraries, backbone-computedfields and backbone-spark, that do. (backbone-spark is apparently heavily based on backbone-mutators).
This would be a great feature to add, and I think would close the major gap that prompted computed-fields and spark to be created. To make sure we're on the same page, let me state what I think the two uses/benefits of this are, and tell me if you agree:
When a field a getter depends on is modified, backbone.mutators will emit a change event for the dependent field, so listeners know the computed value has changed.
Getters declared with dependencies can have their values cached the first time they're accessed, and the computation (the body of the get function) only needs to be run when one of the dependencies is updated.
The first one seems like a slam-dunk to me. The second one seems like a great idea, but it worries me a little, because backbone.mutators can't really tell if your get function depends on, and only on, the fields listed independs. This means that if somebody adds a depends field to a getter, but doesn't actually declare every field the getter depends on, then the getter could return stale results from its cache.
+1 for this feature. We use Mutators along side BB Stickit, so without this feature stickit wont correctly update our 'bound' dom elements when observing a mutator property.
hey @asciidisco,
i may be missing something, but it doesn't look like mutators supports dependent fields, right?
is there any good reason against this? if so, would you recommend any other library?
cheers,
daniel
The text was updated successfully, but these errors were encountered: