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

[v2] Use @tracked underneath on Ember 3.16+ #354

Closed maxfierke closed 4 years ago

maxfierke commented 4 years ago

This is a PR to use @tracked for Task and TaskInstance state on Ember 3.16+ to enable use without using @computed when consuming derived state.

In Ember < 3.16, e-c behaves as it currently does requiring @computed to track task-derived state changes.

This PR essentially replaces the state properties on the Ember implementations of Task and TaskInstance with those properties decorated with @tracked (done dynamically, though w/ property descriptors. not redefining them with actual decorator syntax, so there's no dependency on decorator transforms.) This incurs a little bit of a cost, since it's redefining the properties, but practically shouldn't have much effect since it's applied to the Task and TaskInstance prototypes, rather than every instance, so it would only be incurred once.

There's a few outstanding issues/open questions with this:

I'd expect there are probably other edge-cases with this as well.

Resolves #343