Open buschtoens opened 5 years ago
Related to https://github.com/machty/ember-concurrency-decorators/issues/30#issuecomment-455184343 and #35.
Create a babel transform that converts the following assignment syntax to decorator syntax:
import { task, restartableTask } from 'ember-concurrency-decorators'; class Foo { @restartableTask({ maxConcurrency: 5 }) bar = task(function*(this: Foo) { // ... }); }
import { restartableTask} from 'ember-concurrency-decorators'; class Foo { @restartableTask({ maxConcurrency: 5 }) bar = function*(this: Foo) { // ... }; }
Using task in assignment syntax allows us to provide valid types for TypeScript.
task
Since we're applying a Babel transform now anyway, we can also remove the decorator usage at runtime completely by using Ember.defineProperty.
Ember.defineProperty
import { task } from 'ember-concurrency'; import { defineProperty } from '@ember/object'; class Foo {} defineProperty( Foo.prototype, 'bar', task(function*(this: Foo) { // ... }).maxConcurrency(5).restartable() );
Related to https://github.com/machty/ember-concurrency-decorators/issues/30#issuecomment-455184343 and #35.
Create a babel transform that converts the following assignment syntax to decorator syntax:
Using
task
in assignment syntax allows us to provide valid types for TypeScript.Since we're applying a Babel transform now anyway, we can also remove the decorator usage at runtime completely by using
Ember.defineProperty
.