Detect when all components are initialized? #1257
-
Is there a way to run code after Alpine.js initialized all components? {
arr: [],
start() {
Alpine.onComponentInitialized((component) => {
// analyze and add data to this.arr
}
// call method that use this.arr
this.run()
},
run() {
console.log(this.arr)
// this.arr is empty since the components arent initialized yet
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
here is the source of the plugin if the example isn't clear enough |
Beta Was this translation helpful? Give feedback.
-
Could you check the length of this array matches the length of components, and keep polling until it's ready? |
Beta Was this translation helpful? Give feedback.
Could you check the length of this array matches the length of components, and keep polling until it's ready?