Run a function when target variable changes
Hedronmx opened this issue · 1 comments
Hedronmx commented
Is it possible to call a function every time a target variable changes??
arguiot commented
Yes! It's actually written in the docs
⚠️ The$.target() can accept a callback function to do other things than just render, but if you're using this method, the $ .var() function won't be automatically called, so don't forget to do it manually 😊.
So, you can just do:
$.target(() => {
// Do whatever here
$.var() // render everything, because it won't be triggered automatically otherwise
})