machty / ember-concurrency

ember-concurrency is an Ember Addon that enables you to write concise, worry-free, cancelable, restartable, asynchronous tasks.
http://ember-concurrency.com
MIT License
690 stars 157 forks source link

ember-concurrency is not working in ember-utility #347

Closed vinodhrajamuralidharan closed 4 years ago

vinodhrajamuralidharan commented 4 years ago

I am trying to use ember-concurrency tasks in my custom ember utility file. But it throws an error.

maxfierke commented 4 years ago

@vinodhrajamuralidharan Can you provide the error message and a stacktrace, and a snippet of the code for how you're using ember-concurrency within this utility file?

vinodhrajamuralidharan commented 4 years ago

If I write any task inside, I get build error. Though I import at the top, it does not understand the task keyword.

Is there anything I have to do differently?

maxfierke commented 4 years ago

@vinodhrajamuralidharan It would be hard for me to provide any guidance without some additional context (code, stacktrace, etc.)

vinodhrajamuralidharan commented 4 years ago

I understand. I get this error when I add a concurrency task in the utility file, 'error Parsing error: Unexpected token :' and the code I added is,

Screenshot 2020-02-29 at 21 39 15

Correct me if I am doing anything wrong here in the utility file. I have used in other places and it works great. In the utility, I am trying the very first time.

maxfierke commented 4 years ago

@vinodhrajamuralidharan looks like insights is a function, not an ember object or class, so you cannot attach properties to it like that, (or ember-concurrency tasks)

You may be going for something like this?

export const insights = EmberObject.extend({
   store: service(),

   fetchItems: task(function*(params) {
     // ...
   })

   // ...
});
vinodhrajamuralidharan commented 4 years ago

I just tried in the plain util file. I understand now, ember-concurrency will only work on EmberObject and class. - Thanks