Open theSherwood opened 7 months ago
Thanks for the ideation! Sounds like a good idea in general to be able to react to changes of (derive from) certain variables.
Thoughts?
I think the callback approach is good because it will cost initial memory for the callbacks, and after that will only be calling the callbacks upon updates if the callbacks exist, whereas if the updateVariables
method returns a new array of modified variables on each call, that could add higher runtime cost for every calculation in creating the new arrays (imagining it running during animation). I think that the subscription is also more common of a pattern people will be familiar with.
Also added a comment in the PR.
Is there any easy way to see which variables have changed during a call to
solver.updateVariables
? The api doesn't seem to give me a convenient way to incrementally update anything depending on the kiwi solver's state (such as UI), without checking each variable individually.2 possible approaches for the API that spring to mind are:
solver.updateVariables
Thoughts?