cassowary.js icon indicating copy to clipboard operation
cassowary.js copied to clipboard

Variable change notification support

Open slightlyoff opened this issue 13 years ago • 4 comments

The common use-case for Cassowary-based systems is for the solver to run in an incremental mode, moving to a new solution from an existing good solution. In interactive apps, the initial new values may be provided, but it's up to the solver to efficiently find new values for other affected variables. The updated values often need to be fed back into a UI framework to perform on-screen updates.

Cassowary should provide an (optional) facility for notifying observers of variables who values have changed, perhaps as a Map()/HashMap().

slightlyoff avatar Jun 27 '12 13:06 slightlyoff

Note that the API and notification format should be broadly compatible with the Object.observe() straw-man:

http://wiki.ecmascript.org/doku.php?id=strawman:observe

slightlyoff avatar Jun 29 '12 15:06 slightlyoff

I've been using Ember's Object Model & Observers, it's not compliant with the Object.observe() straw-man, but good-enough for my needs. Basically I just wrapped constraintVariable.change_value and constraintVariable.set_value

... I'm addicted to Ember's computed properties.

d4tocchini avatar Sep 05 '12 05:09 d4tocchini

What is the intersection between this and the new API? Is it still worth making the internal Variable objects observable?

asolove avatar May 09 '13 20:05 asolove

I think that a parser-based API would benefit from this by allowing you to register some sort of event handler to know that values of interest were modified.

slightlyoff avatar May 11 '13 01:05 slightlyoff