-
-
Notifications
You must be signed in to change notification settings - Fork 126
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
Feature Request: whenAsync #66
Comments
Yes makes perfect sense!
Op vr 28 jul. 2017 00:45 schreef Samuel Greene <notifications@github.com>:
… I have a few use cases where I'd like a promise for when an observable is
set with a certain value. when is awesome, but it effectively takes a
callback for when the predicate returns true instead of resolving a promise.
I've implemented this as whenAsync like so:
let whenAsync = fn => new Promise(resolve => when(fn, resolve))
And I use it like this:
await whenAsync(() => !state.someBoolean)
It's especially useful for detecting when boolean values change, e.g.
getting a promise for when a modal closes, something finishes loading, etc.
It's also useful for testing. We have utils here to convert from a promise
to an observable, but not the other way around.
Would something like this be useful as a pull request?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#66>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABvGhOo9KHItDKrQ-5B1zYM-BEJGKPiEks5sSRLwgaJpZM4Ol7kE>
.
|
Awesome, I'll add a PR for it! |
Merged
Hi there! I've taken a quick stab at a PR adding |
@mweststrate Any update on this? I've had a PR open for a while |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have a few use cases where I'd like a promise for when an observable is set with a certain value.
when
is awesome, but it effectively takes a callback for when the predicate returns true instead of resolving a promise.I've implemented this as
whenAsync
like so:And I use it like this:
It's especially useful for detecting when boolean values change, e.g. getting a promise for when a modal closes, something finishes loading, etc. It's also useful for testing. We have utils here to convert from a promise to an observable, but not the other way around.
Would something like this be useful as a pull request?
The text was updated successfully, but these errors were encountered: