-
-
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
Does not work with native classes #271
Comments
Duplicate of #241 |
The three solutions are:
|
OK, perhaps it's worth updating the docs to reflect that, as this issue is likely to come up more frequently as the community marches forward |
Totally agree that this needs to be documented, as I always forget what the rules are myself. Would also appreciate a section in the doc on what the rules/options are for TypeScript. I'm very busy lately (and also a tad rusty) so I'd very much welcome a docs PR on this stuff. |
Hmm, I'm seeing the "classic" syntax generating that error:
References (-task-property.js:398):
|
@aaronbhansen I am experiencing the same thing after moving from Ember 3.5 --> Ember 3.6. During this process I was upgraded from Babel 6 --> Babel 7. Could this be part of the issue? |
@crhayes After some random shots in the dark, I made sure that ember-concurrency was running X.X.26, which required upgrading other dependencies (like ember-power-select and an internal add-on we maintain), did this looking within |
@buschtoens Thanks! I realize (after checking my I have an in-repo-addon that also uses |
For completeness sake: In the Octane edition of Ember.js, you can create a task like this: class MyClass {
@task(function*() {
// ...
}) myTask;
} |
@buschtoens i think you're maybe missing a closing paren?
|
@gabrielgrant That is correct, thanks! I updated the snippet. :) |
What’s the correct syntax for a task using typescript with ember 3.11? |
@BryanCrotaz The issue is that decorators cannot (yet) influence the type signature. To circumvent this, I made |
Could we start by adding an example to the Task Function Syntax page? Or do we also need to cover the caveats/edge cases for it to be merged? Example gist: https://gist.github.com/jenweber/443dac9876c7ef2b1115093cfd5d6fac |
Raised in issue #271, there is currently no official documentation on using ember-concurrency with native classes and other Octane-related use-cases. This adds a brief section to "Task Function Syntax" in the docs that shows an example of use with a Glimmer component and mentions the ember-concurrency-decorators addon as a more concise approach to the default decorators via the task() property.
Raised in issue #271, there is currently no official documentation on using ember-concurrency with native classes and other Octane-related use-cases. This adds a brief section to "Task Function Syntax" in the docs that shows an example of use with a Glimmer component and mentions the ember-concurrency-decorators addon as a more concise approach to the default decorators via the task() property.
Closing this out, since documentation has been added on using with native classes on Ember 3.10+. More specific issues w/ native classes, decorators, etc. can be addressed in separate issues as needed in the future. |
Using Ember 3.6, ember-concurrency 0.8.26
Given a component defined with 'classic' syntax, all is good.
If, however, we use native class syntax
We see
-task-property.js:620 Uncaught Error: It looks like you tried to perform a task via this.nameOfTask.perform(), which isn't supported. Use 'this.get('nameOfTask').perform()' instead.
I've spent a little time trying to figure out why this is the case and have found that when creating a TaskProperty, the function passed to
super
does not get executed https://github.com/machty/ember-concurrency/blob/master/addon/-task-property.js#L416-L437The transpiled output of the classic invocation is
Whilst the native version is
So it looks like it's caused by the way the property ends up being defined on the native class that is causing the issue.
The text was updated successfully, but these errors were encountered: