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

Consider subscribeWithSelector for node value updates #483

Open
funwithtriangles opened this issue Jan 3, 2025 · 1 comment
Open

Consider subscribeWithSelector for node value updates #483

funwithtriangles opened this issue Jan 3, 2025 · 1 comment

Comments

@funwithtriangles
Copy link
Member

Currently we mutate state for node values and then all params are checking to see if these values are updated on an interval. This is historically performance reasons, but maybe it makes sense to subscribe to changes using Zustand. That way, we're not constantly updating canvases for sliders or classes for booleans unless there's actually been a change.

This might come with other kinds of overhead so it needs investigating.

@funwithtriangles
Copy link
Member Author

As far as I can tell, every time state is changed in Zustand, it runs through a list of active subscribers and they all do their equality functions to know whether to fire.

If we have multiple updates per second (e.g. multiple inputs), this would mean Zustand runs through that list verrrry often. In practice, that list would be visible params.

This could be sensible if the inputs batched their updates so they only made one state change every frame. It still feels a bit pointless, as right now the components just check state every frame anyway.

It might make more sense to prevent canvas/Dom updates by just having the component only do those imperative updates if the incoming value has changed.

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

No branches or pull requests

1 participant