Closed
Conversation
Contributor
|
Would this cause an issue with In case this doesn't get merged, or if you want the functionality now, you can add a magic helper to get (perhaps?) the behavior you want: **I put this together quickly so I haven't tested it much! You likely would want to customize it and iron out any edge cases you encounter. |
Collaborator
|
Thanks for the PR @inxilpro, this makes a lot of sense, however I'm not going to merge it into this version for the sake of stability. Fortunately, I've already added this functionality to V3 though, so it will be available when that comes out. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Right now
x-initonly fires on root components (i.e. DOM nodes withx-dataattributes). This PR lets child nodes also addx-initcalls.The primary use-case is when Alpine code is being generated by a templating language, like Blade. Typically an Alpine component would just initialize all of its state in one
x-initorx-datastatement, but if you're composing functionality with templates, your initial state may be spread through the entire DOM tree.The real-world use-case is that I'm working on an Algolia InstantSearch implementation in Blade and Alpine. Here's a sample of the API:
If
x-initwas called on all sub-components, the resulting code could look like: