4 ms·
I used it in a few project. And it reduces the code by a lot. For example. To make a mutex to prevent duplicate submit of form. You use need to declare a inst
by mmis1000 4y ago
I used it in a few project. And it reduces the code by a lot.
For example. To make a mutex to prevent duplicate submit of form. You use need to declare a instance field and wraps the code that do the submit. That alone is 3 lines of code but don't even include error handling.
But now I sealed it into a one line hook
const wrap = useMutex()
const submit = wrap(async () = { … })
And then the submit can't run in parallel now.