-
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for async predicate #3
Comments
@louiealmeda Just add |
@louiealmeda PR created in #4 I didn't use |
that's awesome @zorji I hope it gets pulled in. |
Hi @devlato just wondering if you are going to merge this pull request? We have the same need. Thank you very much. |
Hello, I also have a need for this. Looking forward to getting the new changes. Do you know when it'll be available? Thanks for your hard work and making such a useful library. |
@louiealmeda why don't you just do this 🙂 while (true) {
const response = await api.get(); // Any async operation
if (response.status === 200) {
break;
}
} In case of async predicate, there's a natural way of pausing and proceeding the execution flow, so the above snippet would solve your issue 🤷♂️ |
Otherwise, as per this library design, it should do the following:
If this behaviour is what you would expect from the library, I'm keen to make change and publish an updated version. |
Hi @devlato, thanks for looking into this. Indeed, we can do the solution that you've posted, but it can quickly become messy when we need to do a lot of waits, especially when we want to set timeouts for them. I believe it is that problem that this library is actually solving... Yes the flow seems correct to me, and looks aligned with @zorji's PR Cheers. |
It seems it's possible to carry on the discussion in this thread, I'll close my PR A better implementation should consider wait AFTER the previous Promise resolved but since I don't need the change any more I'll close mine. |
Hey folks, have just merged v2.0.0 (#5) and will publish it to npm shortly. The updated documentation is available in the project README. Additionally, auto-generated documentation is available on GitHub Pages. |
I'm closing this issue, please re-open or create a new one if this is still an issue after upgrading to 2.0.0. |
There are use cases that would need to repeatedly call an async operation until a certain condition is met. For instance, an API call.
something like:
Currently, having an
async
predicate
skips the waitUntil predicate entirelyThe text was updated successfully, but these errors were encountered: