Source: ryangjchandler.co.uk

The Magic Behind Reactivity - Effects

Category: nodejs

We think you might be interested in this job:

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.
Community Partners