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
691 stars 157 forks source link

Restore access to host context from encapsulated tasks #401

Closed maxfierke closed 3 years ago

maxfierke commented 3 years ago

It was inadvertently removed when re-implementing encapsulated tasks with Proxy. However, it's a useful feature for implementing sort-of "higher-order tasks" and since there's no viable replacement, this PR reintroduces it. It is, however, considered intimate, undocumented API that will not be covered under SemVer guarantees.

Because it can be read from this, it can be accidentally overwritten by user code. A future solution might be to provide some sort of getHostContext() yieldable to provide the value within task execution and avoid the need to access it directly.

For now, restoring it will allow folks who depended on such undocumented behavior to upgrade to 2.0.0.