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

fix: watch for structural changes on objects and arrays #3

Merged
merged 7 commits into from
Mar 10, 2025

Conversation

anthonyshort
Copy link
Contributor

When doing something like this:

effect(() => {
  state.todos.forEach((todo) => console.log(todo));
});

I'd expect it to run when I add/remove items from the todo list. This change adds this in a pretty naive way by looking to see if the keys have changed on objects and arrays.

Copy link

codesandbox-ci bot commented Mar 9, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@dai-shi
Copy link
Member

dai-shi commented Mar 10, 2025

Nice catch. Let me take it over as I think there should be a better implementation.

@anthonyshort
Copy link
Contributor Author

Nice catch. Let me take it over as I think there should be a better implementation.

Thank you!

@dai-shi dai-shi changed the title watch for structural changes on objects and arrays fix: watch for structural changes on objects and arrays Mar 10, 2025
Copy link
Member

@dai-shi dai-shi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be good.

@dai-shi dai-shi merged commit 7f40856 into valtiojs:main Mar 10, 2025
2 checks passed
@dai-shi
Copy link
Member

dai-shi commented Mar 10, 2025

Published: https://www.npmjs.com/package/valtio-reactive/v/0.1.2

Thanks for your contribution!

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 this pull request may close these issues.

2 participants