Using 'this' when calling a function in a store #4067
Answered
by
ekwoka
docdunning
asked this question in
1. Help
-
I've found that it's important to use brackets when calling a function in a store from an Alpine directive. If the function is in the For a function in a Why does this happen?
|
Beta Was this translation helpful? Give feedback.
Answered by
ekwoka
Mar 4, 2024
Replies: 1 comment 3 replies
-
Wheb the expression is run it's bound to the current data context. If it returns a function, the function is run and bound to the current data context. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
good question, but no.
if you image it like
then the two you mention would be liek
the first is simply evaluating to a function.
The second is calling the function and resolving to whatever that function returns.
In the second,
storedata()
is invoked as a method onmystore
.In the first,
storedata
is isolated separately from the object, and then called with the$data
as the lexically boundthis
.