x-defer, x-reloaded, Control components lifecycle #653
Replies: 4 comments 11 replies
-
|
I think anything that allows for Alpine to be extended through plugins and other abstraction will be useful to me. Personally, I'd also like all Alpine events to be fired on the window, for example when Alpine discovers a new component and about to initialize it. Here's some examples of current ways to accomplish some of the above, in case it's useful now to someone:
Looking forward to thoughts from others. |
Beta Was this translation helpful? Give feedback.
-
|
Great idea! Would be a godsend for people working with Livewire/Turbolinks stack |
Beta Was this translation helpful? Give feedback.
-
|
I think there are a few challanges.
As a separate note, Ryan created a PR to add lifecycle events in the past but it was decided not to merge it. It would be good to know what other people's (and Caleb's) thoughts are. |
Beta Was this translation helpful? Give feedback.
-
|
With the help from people participating in this discussion I learned that these two exist: For my needs, they are enough so I'll close this thread. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
It would be great if one could take control of a components lifecycle,
a missing piece when Alpine has to co-exist with other libs like Turbolinks or any js that loads serverside rended html fragments that could contain alpinejs.
(Revised edition, after comment from @SimoTod )
Directives
Hooks
Alpine.reload( refName )
Event handler:
reloaded( ) { ... }
Example:
inline
js
x-defer="windowEvent"
The
x-deferdirective should tell Alpine to defer the initial loading to the named window event. Would requirex-cloakto avoid flickering.Alpine.reload(refName)
Should trigger alpine to reinitiate the named component and run the
x-reloadeddirective.window.deferLoadingAlpine
I've seen that there are topics on taking control of Alpines loading state with this method but this feature request targets individual component control instead of interfering with all.
Beta Was this translation helpful? Give feedback.
All reactions