Question on using state-derived on... event handlers #368
Replies: 1 comment 1 reply
-
Hi @deepakmecheri, Thanks for reaching out! The 2 pieces of code you pasted have equivalent semantic. But their underlying implementations are different. Code 1: button({onclick: van.derive(() => action.val === "👍" ?
() => ++counter.val : () => --counter.val)}, "Run"), The click event handler will be different depending on the Code 2: button({onclick: () => action.val === "👍" ? ++counter.val : --counter.val}, "Run"), The click event handler remains the same regardless of the In theory, if the click event handler is frequently executed while the Hope it explains :-) |
Beta Was this translation helpful? Give feedback.
-
In the VanJS tutorial page it is mentioned that
But when I run the example that is given on the page by removing the
van.derive
wrapper, it still works!i.e
and
seem to work practically the same. Can someone please help me understand what the actual meaning of this section is.
Beta Was this translation helpful? Give feedback.
All reactions