Alpine.store property not reactive? #3090
-
I have a scroll event listener on the window:
The event handler function:
The console.log correctly prints the value of
It's always |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Yup, struggling with the same behavior. I am infact using the exact same example from the docs https://alpinejs.dev/globals/alpine-store |
Beta Was this translation helpful? Give feedback.
-
Can you show the whole component? But yes, as shown there. When you don't do the Basically with It's like addEventListener('scroll', ()=>$store.thing.function) While without is like addEventListener('scroll', $store.thing.function) I'm sure you've seen how this changes how methods on objects work. With methods on the current component, without still works because of how Alpine tries to "correct" for this by using the component as the If you check for the |
Beta Was this translation helpful? Give feedback.
Okay, got it work. It seems like you will have to call the function explicitly. Make the following changes in your code for it work.