-
-
Notifications
You must be signed in to change notification settings - Fork 157
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 waitFor()-type modifiers in async arrow transform #536
Conversation
This is an alternative to #531 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, approach looks good to me. Appreciated all the comments, as well. Left a couple of small suggestions. Looks like there's some interaction with @embroider/macros
based on the CI results, though.
74b1254
to
1891b0e
Compare
@maxfierke I addressed your two pieces of feedback along with a couple more clarifying comments (and rebased them into the original commit). Once #537 is merged I'll rebase this onto If we're feeling confident we're going to go with this approach, then I could use some advice on updating documentation -- I'm not really sure where it makes sense to mention this support for modifier functions. Also, I'm not sure if it's worth talking about it in general, or just document the |
1891b0e
to
8caf51a
Compare
I think it's probably reasonable to stick to documenting the If you're looking for a spot, the "Testing/Debugging" page is probably a good place since it'll be |
8caf51a
to
2bb96ff
Compare
Update the async arrow task babel transform to allow the task function to be wrapped in any "modifier functions" such as `waitFor` from `@ember/test-waiters`, and preserve that wrapping in the output. Note that this is a little screwy from a types perspective because these modifier functions must by typed to accept an async function, but at runtime are actually passed generator functions. This is fine for `waitFor()` because it accepts both, and maybe this is the only modifier function we'll ever need to support, but it is a kinda funny caveat.
2bb96ff
to
d3e4ee9
Compare
@maxfierke I rebased so the build is passing. I'm actually thinking maybe we don't need to add documentation here? We didn't have explicit document for the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me! I'll get this merged & released this weekend
I'm actually thinking maybe we don't need to add documentation here? We didn't have explicit document for the
waitFor()
usage before, and just rely on the documentation in@ember/test-waiters
I do think it'd be useful to at least link out to those @ember/test-waiters docs from the e-c docs once they're available, but we can do that in a follow-up PR
Glad to see work on this! I've been using ember-test-waiters with ember-concurrency for a while and had a lot of trouble here. Is this the expected syntax for usage? queryStats = task(
{ restartable: true },
waitFor(async (query: typeof this.query) => {
// stuff
}),
) or this with the decorator? @waitFor
queryStats = task({ restartable: true }, async (query: typeof this.query) => {
// stuff
}),
) Also, types seem to be an issue :/ is this something for e-c to fix or for ember-test-waiters? There's an open issue over here
|
@Techn1x the first non-decorator usage is the correct one. It's not typechecking because the In the meantime I'd probably recommend using |
Ah! Fantastic. Didn't see that PR, I'll go link it to the issue over there and hopefully that'll help. Thanks a bunch! I am using pnpm so I'll probably patch it with that in the meantime |
@Techn1x I'm not sure...does it still produce the error if you remove the |
@Techn1x @bendemboski I tried the upstream change locally and can see that it resolved those issues. |
Update the async arrow task babel transform to allow the task function to be wrapped in any "modifier functions" such as
waitFor
from@ember/test-waiters
, and preserve that wrapping in the output.Note that this is a little screwy from a types perspective because these modifier functions must by typed to accept an async function, but at runtime are actually passed generator functions. This is fine for
waitFor()
because it accepts both, and maybe this is the only modifier function we'll ever need to support, but it is a kinda funny caveat.