DEV Community

Discussion on: Introducing the Async Debounce pattern

 
leoyli profile image
Leo Y. Li

There are no threading in JS, JS run-time env is single-thread. I guess the library is doing something for request aborting under the hood, which is very common and can be easily done with Axios lib. As for the state machine, xstate is one worthy to check it out.

I'm really like this article which inspires me plan my state machine with xstate. Thanks!

Thread Thread
 
xowap profile image
Rémy 🤖

Indeed, as @leoyli explained, JS has no threads because it follows a completely async paradigm. Which is kinda good but it just took 20 years to get the actual tools to deal with it.

I understand better your vision and actually you're not the first one to tell me this so I might think about it and produce something to solve that need too. However that's outside the scope of what I intended here.

To be specific, I deal a lot with things like "filter forms" where the user chooses filters which instantly impact the displayed results. In that case, only the latest state of the filters matters because you're only displaying the results currently matching the filters. That's why discarding intermediate queries makes sense!