Source: ryangjchandler.co.uk

The Magic Behind Reactivity - Effects

Category: nodejs

In the previous instalment, we created a reactive function that accepts an object and returns a new Proxy instance. If you're not sure what a Proxy is or how it works, definitely go back and read that post. In this post, I'll be creating an effect function that will allow us to react to changes on the Proxy and update the DOM.

What we can do is store all the effect callbacks in an array and call each one when our Proxy is updated.

We now have a reactive object and an effect function that is invoked each time a relevant property in our data is updated.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners