Skip to content

Commit 2de9cef

Browse files
authoredFeb 15, 2021
Merge pull request #398 from machty/mf-v2_release_finalization
v2 release finalization
2 parents 99e677d + e359528 commit 2de9cef

13 files changed

+122
-87
lines changed
 

‎.github/workflows/ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
push:
66
branches:
77
- master
8+
- v1
89
- v2
910
# npm version tags
1011
- /^v\d+.\d+.\d+(?:-(?:alpha|beta|rc)\.\d+)?/

‎API.md

+17-5
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,24 @@ most of the time, you'll only be using the `task` and `timeout`
66
imports, e.g.:
77

88
```js
9+
import Component from '@glimmer/component';
10+
import { tracked } from '@glimmer/tracking';
911
import { task, timeout } from 'ember-concurrency';
1012

11-
export default Component.extend({
12-
loopingTask: task(function * () {
13+
export default class MyCompontent extends Component {
14+
@tracked num;
15+
16+
constructor() {
17+
super(...arguments);
18+
this.loopingTask.perform();
19+
}
20+
21+
@task *loopingTask() {
1322
while (true) {
14-
this.set('num', Math.random());
23+
this.num = Math.random();
1524
yield timeout(100);
1625
}
17-
}).on('init')
26+
}
1827
});
1928
```
2029

@@ -44,6 +53,9 @@ used in conjunction with Tasks / TaskInstances.
4453

4554
## Misc
4655

56+
- [animationFrame](global.html#animationFrame)
57+
- [didCancel](global.html#didCancel)
58+
- [forever](global.html#forever)
59+
- [rawTimeout](global.html#rawTimeout)
4760
- [waitForEvent](global.html#waitForEvent)
4861
- [waitForQueue](global.html#waitForQueue)
49-

‎README.md

-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
# v2 Development Branch
2-
3-
This here is the work-in-progress branch for ember-concurrency v2. This will be
4-
merged into master when v2 is ready for release.
5-
61
# ember-concurrency
72

83
[![Build Status][build-status-img]][build-status-link]

‎UPGRADING-2.x.md

+36
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@ semantic changes to the operation of the addon.
1010

1111
## Changes
1212

13+
### Drops support for Ember < 3.8 and Node 8
14+
15+
ember-concurrency 2.0.0 drops support for many older Ember and Node versions.
16+
Usage with 3.8 LTS and up ensures ember-concurrency can depend on the same Ember
17+
runloop semantics (e.g. running on the microtask queue), while still providing a
18+
broad level of compatibility with existing apps.
19+
20+
In some cases, polyfills will be needed for Ember 3.8, for example when using
21+
decorators. See [config/ember-try.js](config/ember-try.js) for the `ember-lts-3.8`
22+
scenario.
23+
24+
ember-concurrency 1.x is still available for those apps needing support back to
25+
Ember 2.4 LTS.
26+
1327
### Decorators from `ember-concurrency-decorators` are built-in
1428

1529
This provides built-in support for the "nice" decorator syntax based on the
@@ -82,6 +96,10 @@ depend on cancelation to finish by awaiting the value of the promise returned by
8296
the cancelation methods on `Task` and `TaskInstance`, `cancelAll` and `cancel`,
8397
respectively.
8498

99+
It should be noted that when calling `cancelAll` with `{ resetState: true }`, the
100+
state reset does not take effect immediately, as it did in e-c 1.x, but happens
101+
on cancelation finalization, making it important to `await` calls to `cancelAll`.
102+
85103
For example,
86104

87105
```javascript
@@ -282,3 +300,21 @@ jobs:
282300
- env: EMBER_TRY_SCENARIO=ember-concurrency-1.x
283301
- env: EMBER_TRY_SCENARIO=ember-concurrency-2.x
284302
```
303+
304+
## FAQ
305+
306+
### Something is broken even though I made sure to do the above updates!
307+
308+
First, make sure that ember-concurrency 2.0.0 or higher is the version that is
309+
being loaded and used by your application. It's often the case that an addon
310+
might be pinned to an older version and is pulling that in and it's being used
311+
instead. Check `yarn why ember-concurrency` to see how the versions are being
312+
resolved, if you're a `yarn` user. For npm, use whatever available equivalents.
313+
314+
You may need to contact the maintainer of another addon to get them to release
315+
a version with support for ember-concurrency 2.0.0 (point them to this guide!)
316+
or you might be able to workaround it with Yarn resolutions, as the APIs are
317+
largely compatible between the two versions.
318+
319+
If you've verified the proper version of ember-concurrency is being loaded and
320+
you still are seeing the issue, please reach out on Discord or open an issue here.

‎addon/-private/external/yieldables.js

+13-14
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ class RawTimeoutYieldable extends Yieldable {
107107
* for every animation frame.
108108
*
109109
* ```js
110-
* export default Component.extend({
111-
* myTask: task(function * () {
110+
* export default class MyComponent extends Component {
111+
* &#64;task *myTask() {
112112
* let lastNow = performance.now();
113113
* while (true) {
114114
* yield animationFrame();
@@ -119,8 +119,8 @@ class RawTimeoutYieldable extends Yieldable {
119119
*
120120
* console.log(dt);
121121
* }
122-
* })
123-
* });
122+
* }
123+
* }
124124
* ```
125125
*/
126126
export function animationFrame() {
@@ -148,14 +148,13 @@ export function animationFrame() {
148148
*
149149
* ```js
150150
* import { task, forever } from 'ember-concurrency';
151-
*
152-
* export default Component.extend({
153-
* myService: service(),
154-
* myTask: task(function * () {
151+
* export default class MyComponent extends Component {
152+
* &#64;service myService;
153+
* &#64;task *myTask() {
155154
* yield this.myService.doSomethingThatCausesATransition();
156155
* yield forever;
157-
* })
158-
* });
156+
* }
157+
* }
159158
* ```
160159
*/
161160
export const forever = new ForeverYieldable();
@@ -183,14 +182,14 @@ export function raw(value) {
183182
* console every second.
184183
*
185184
* ```js
186-
* export default Component.extend({
187-
* myTask: task(function * () {
185+
* export default class MyComponent extends Component {
186+
* &#64;task *myTask() {
188187
* while (true) {
189188
* console.log("Hello!");
190189
* yield rawTimeout(1000);
191190
* }
192-
* })
193-
* });
191+
* }
192+
* }
194193
* ```
195194
*
196195
* @param {number} ms - the amount of time to sleep before resuming

‎addon/-private/task-instance.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export class TaskInstance extends BaseTaskInstance {
154154
* `on` from `@ember/object/evented` may be used to create a binding on the host object to the event.
155155
*
156156
* ```js
157-
* export default Ember.Component.extend({
157+
* export default Component.extend({
158158
* doSomething: task(function * () {
159159
* // ... does something
160160
* }),
@@ -175,7 +175,7 @@ export class TaskInstance extends BaseTaskInstance {
175175
* `on` from `@ember/object/evented` may be used to create a binding on the host object to the event.
176176
*
177177
* ```js
178-
* export default Ember.Component.extend({
178+
* export default Component.extend({
179179
* doSomething: task(function * () {
180180
* // ... does something
181181
* }),
@@ -197,7 +197,7 @@ export class TaskInstance extends BaseTaskInstance {
197197
* `on` from `@ember/object/evented` may be used to create a binding on the host object to the event.
198198
*
199199
* ```js
200-
* export default Ember.Component.extend({
200+
* export default Component.extend({
201201
* doSomething: task(function * () {
202202
* // ... does something
203203
* }),
@@ -219,7 +219,7 @@ export class TaskInstance extends BaseTaskInstance {
219219
* `on` from `@ember/object/evented` may be used to create a binding on the host object to the event.
220220
*
221221
* ```js
222-
* export default Ember.Component.extend({
222+
* export default Component.extend({
223223
* doSomething: task(function * () {
224224
* // ... does something
225225
* }),

‎addon/-private/task-properties.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ Object.assign(TaskProperty.prototype, propertyModifiers, {
132132
* when the host object is initialized.
133133
*
134134
* ```js
135-
* export default Ember.Component.extend({
135+
* export default Component.extend({
136136
* pollForUpdates: task(function * () {
137137
* // ... this runs when the Component is first created
138138
* // because we specified .on('init')

‎addon/-private/utils.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ class TimeoutYieldable extends EmberYieldable {
5959
* console every second.
6060
*
6161
* ```js
62-
* export default Component.extend({
63-
* myTask: task(function * () {
62+
* export default class MyComponent extends Component {
63+
* &#64;task *myTask() {
6464
* while (true) {
6565
* console.log("Hello!");
6666
* yield timeout(1000);
6767
* }
68-
* })
69-
* });
68+
* }
69+
* }
7070
* ```
7171
*
7272
* @param {number} ms - the amount of time to sleep before resuming

‎addon/-private/wait-for.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ class WaitForPropertyYieldable extends EmberYieldable {
124124
*
125125
* ```js
126126
* import { task, waitForQueue } from 'ember-concurrency';
127-
* export default Component.extend({
128-
* myTask: task(function * () {
127+
* export default class MyComponent extends Component {
128+
* &#64;task *myTask() {
129129
* yield waitForQueue('afterRender');
130130
* console.log("now we're in the afterRender queue");
131-
* })
132-
* });
131+
* }
132+
* }
133133
* ```
134134
*
135135
* @param {string} queueName the name of the Ember run loop queue
@@ -145,8 +145,8 @@ export function waitForQueue(queueName) {
145145
*
146146
* ```js
147147
* import { task, waitForEvent } from 'ember-concurrency';
148-
* export default Component.extend({
149-
* myTask: task(function * () {
148+
* export default class MyComponent extends Component {
149+
* &#64;task *myTask() {
150150
* console.log("Please click anywhere..");
151151
* let clickEvent = yield waitForEvent($('body'), 'click');
152152
* console.log("Got event", clickEvent);
@@ -155,8 +155,8 @@ export function waitForQueue(queueName) {
155155
* console.log("Got foo event", emberEvent);
156156
*
157157
* // somewhere else: component.trigger('foo', { value: 123 });
158-
* })
159-
* });
158+
* }
159+
* }
160160
* ```
161161
*
162162
* @param {object} object the Ember Object, jQuery element, or other object with .on() and .off() APIs
@@ -187,24 +187,24 @@ export function waitForEvent(object, eventName) {
187187
*
188188
* ```js
189189
* import { task, waitForProperty } from 'ember-concurrency';
190-
* export default Component.extend({
191-
* foo: 0,
190+
* export default class MyComponent extends Component {
191+
* &#64;tracked foo = 0;
192192
*
193-
* myTask: task(function * () {
193+
* &#64;task *myTask() {
194194
* console.log("Waiting for `foo` to become 5");
195195
*
196196
* yield waitForProperty(this, 'foo', v => v === 5);
197197
* // alternatively: yield waitForProperty(this, 'foo', 5);
198198
*
199-
* // somewhere else: this.set('foo', 5)
199+
* // somewhere else: this.foo = 5;
200200
*
201201
* console.log("`foo` is 5!");
202202
*
203203
* // wait for another task to be idle before running:
204204
* yield waitForProperty(this, 'otherTask.isIdle');
205205
* console.log("otherTask is idle!");
206-
* })
207-
* });
206+
* }
207+
* }
208208
* ```
209209
*
210210
* @param {object} object an object (most likely an Ember Object)

‎addon/index.d.ts

+19-18
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ interface AbstractTaskProperty<T extends Task<any, any[]>> extends ComputedPrope
393393
* when the host object is initialized.
394394
*
395395
* ```js
396-
* export default Ember.Component.extend({
396+
* export default Component.extend({
397397
* pollForUpdates: task(function * () {
398398
* // ... this runs when the Component is first created
399399
* // because we specified .on('init')
@@ -1122,8 +1122,8 @@ export function allSettled<T>(values: Iterable<T>): Promise<Array<Settled<T>>>;
11221122
* for every animation frame.
11231123
*
11241124
* ```js
1125-
* export default Component.extend({
1126-
* myTask: task(function * () {
1125+
* export default class MyComponent extends Component {
1126+
* @task *myTask() {
11271127
* let lastNow = performance.now();
11281128
* while (true) {
11291129
* yield animationFrame();
@@ -1134,8 +1134,8 @@ export function allSettled<T>(values: Iterable<T>): Promise<Array<Settled<T>>>;
11341134
*
11351135
* console.log(dt);
11361136
* }
1137-
* })
1138-
* });
1137+
* }
1138+
* }
11391139
* ```
11401140
*/
11411141
export function animationFrame(): Yieldable;
@@ -1219,14 +1219,14 @@ export function race<T>(values: Iterable<T>): Promise<Resolved<T>>;
12191219
* console every second.
12201220
*
12211221
* ```js
1222-
* export default Component.extend({
1223-
* myTask: task(function * () {
1222+
* export default class MyComponent extends Component {
1223+
* @task *myTask() {
12241224
* while (true) {
12251225
* console.log("Hello!");
12261226
* yield timeout(1000);
12271227
* }
1228-
* })
1229-
* });
1228+
* }
1229+
* }
12301230
* ```
12311231
*
12321232
* @param ms The amount of time to sleep before resuming
@@ -1246,14 +1246,14 @@ export function timeout(ms: number): Yieldable;
12461246
* console every second.
12471247
*
12481248
* ```js
1249-
* export default Component.extend({
1250-
* myTask: task(function * () {
1249+
* export default class MyComponent extends Component {
1250+
* @task *myTask() {
12511251
* while (true) {
12521252
* console.log("Hello!");
12531253
* yield rawTimeout(1000);
12541254
* }
1255-
* })
1256-
* });
1255+
* }
1256+
* }
12571257
* ```
12581258
*
12591259
* @param ms The amount of time to sleep before resuming
@@ -1380,13 +1380,14 @@ export function waitForProperty<O extends object, K extends keyof O>(
13801380
* ```js
13811381
* import { task, forever } from 'ember-concurrency';
13821382
*
1383-
* export default Component.extend({
1384-
* myService: service(),
1385-
* myTask: task(function * () {
1383+
* export default class MyComponent extends Component {
1384+
* @service myService;
1385+
*
1386+
* @task *myTask() {
13861387
* yield this.myService.doSomethingThatCausesATransition();
13871388
* yield forever;
1388-
* })
1389-
* });
1389+
* }
1390+
* }
13901391
* ```
13911392
*/
13921393
export function forever(): Yieldable<never>;

0 commit comments

Comments
 (0)