useDeferred #3883
josuelrocha
started this conversation in
Ideas
useDeferred
#3883
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
Motivation
Recently I worked on a project where I needed to create a task that would be solved later, so I researched some libraries for that and because I couldn't find a reliable and up-to-date one, I decided to write my own composable and called it useDeferred. I believe it would be very useful and interesting to have this feature in VueUse.
I'm going to share the source code I wrote here, if it's of interest to you, you can use it as a base, modify and make improvements as you wish, or at least for inspiration to add it to VueUse.
How to use
When the task is ready, resolve it so that the waiting callback is executed.
Improvements to be made
If this composable is approved for VueUse, I believe it is necessary to add the "catch" and "finally" methods, as I only did the "then" method, because that was what I needed at the moment.
Beta Was this translation helpful? Give feedback.
All reactions