Skip to content
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

[Feature Request] incremental update notification #6

Open
theSherwood opened this issue Jan 19, 2024 · 1 comment · May be fixed by #8
Open

[Feature Request] incremental update notification #6

theSherwood opened this issue Jan 19, 2024 · 1 comment · May be fixed by #8

Comments

@theSherwood
Copy link
Contributor

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:

  1. Having the variable constructor take a callback
type VariableConstructor = (name?: string, callback: (variable: Kiwi.Variable, new_value: any) => void) => Kiwi.Variable;
  1. Returning a list of tuples of dirty variables and their new values from solver.updateVariables
type VariableValue = any;
type SolverUpdateVariables = (this: Kiwi.Solver) => [Kiwi.Variable, VariableValue][];

Thoughts?

@theSherwood theSherwood linked a pull request Jan 23, 2024 that will close this issue
@trusktr trusktr linked a pull request Jan 25, 2024 that will close this issue
@trusktr
Copy link
Member

trusktr commented Jan 25, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants