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 scope, Support nested properties, Support watch deep #294

Conversation

ahmedkandel
Copy link
Contributor

Replaces #292

@ahmedkandel
Copy link
Contributor Author

Here is a codepen to cover watch cases:
https://codepen.io/tomorrowsystem/pen/BaNPpXz?editors=1001

@ahmedkandel
Copy link
Contributor Author

It may need some refactoring, While it will not be easy to get rid of recursive iterations.

Move watcher constructor inside component constructor
@ahmedkandel ahmedkandel changed the title Fix: $watch and Support nested properties And deep watch Fix $watch scope, Support nested properties, Support watch deep Mar 20, 2020
@ahmedkandel
Copy link
Contributor Author

What do you think guys? Is this updated implementation better?
@calebporzio @HugoDF @SimoTod

@calebporzio
Copy link
Collaborator

I'm going to close this for now and only support shallow "watching" in Alpine V2. I believe this feature will just work out of the box with the new v3 reactivity engine.

I know this wasn't an easy implementation, so thank you for the contribution 🙏

@MrSnoozles
Copy link

MrSnoozles commented Oct 18, 2021

v3 still does not support watch deep, does it? (I just came back to Alpine after last trying V2 and made a small example project. At least I couldn't get it to work and it's not mentioned in the docs either.)

@ryangjchandler
Copy link
Contributor

@MrSnoozles haven't tried it myself but you might be able to achieve deep-watching with Alpine.effect().

@justingolden21
Copy link

How many months or years has this been? I still can't watch an object? How am I supposed to react to changes to the object? DO I need to attach a listener to literally every single item in the UI that is bound to any part of the object? Doesn't seem productive for a JS framework. Makes many, many UIs impractical if not impossible to write.

@ryangjchandler
Copy link
Contributor

@justingolden21 You can use Alpine.effect() as mentioned in my comment above.

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.

None yet

5 participants