Skip to content

Commit 2276ffc

Browse files
authored
Merge pull request #1088 from emberjs/advance-rfc-1068
Advance RFC #1068 `"Built in tracking utilities for common collections"` (tracked-built-ins, built-in) to Stage Ready for Release
2 parents ff5a842 + ba6f8d6 commit 2276ffc

1 file changed

Lines changed: 33 additions & 15 deletions

File tree

text/1068-tracked-collections.md

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
---
2-
stage: accepted
2+
stage: ready-for-release
33
start-date: 2025-01-12T00:00:00.000Z
4-
release-date: # In format YYYY-MM-DDT00:00:00.000Z
4+
release-date:
55
release-versions:
6-
teams: # delete teams that aren't relevant
6+
teams:
77
- data
88
- framework
99
- learning
1010
prs:
11-
accepted: https://github.com/emberjs/rfcs/pull/1068
11+
accepted: 'https://github.com/emberjs/rfcs/pull/1068'
12+
ready-for-release: 'https://github.com/emberjs/rfcs/pull/1088'
1213
project-link:
13-
suite:
14+
suite:
1415
---
1516

1617
<!---
@@ -118,7 +119,7 @@ import {
118119
trackedObject, trackedArray,
119120
trackedMap, trackedWeakMap,
120121
trackedSet, trackedWeakSet
121-
} from '@ember/reactive';
122+
} from '@ember/reactive/collections';
122123
```
123124

124125
### `trackedObject`, `trackedArray`, `trackedMap`, etc
@@ -149,7 +150,7 @@ Some examples assuming implementation of [RFC#998: Make fn built-in in strict-mo
149150

150151

151152
```gjs
152-
import { trackedArray } from '@ember/reactive';
153+
import { trackedArray } from '@ember/reactive/collections';
153154
154155
const nonTrackedArray = [1, 2, 3];
155156
const addTo = (arr) => arr.push(Math.random());
@@ -187,7 +188,7 @@ const addTo = (arr) => arr.push(Math.random());
187188
#### Example `trackedObject`
188189

189190
```gjs
190-
import { trackedObject } from '@ember/reactive';
191+
import { trackedObject } from '@ember/reactive/collections';
191192
192193
const nonTrackedObject = { a: 1 };
193194
const addTo = (obj) => obj[Math.random()] = Math.random();
@@ -248,6 +249,23 @@ For example, other future exports from `@ember/reactive` (in future RFCs), may i
248249
without the static analysis guarantees of `type=module`, every consumer of `@ember/reactive` would always have all of these exports in their build.
249250
For some utilities, we can place them under sub-path-exports, such as `@ember/reactive/window`, for window-specific reactive properties, but the exact specifics of each of these can be hashed out in their individual RFCs.
250251

252+
#### Why are the collections under `@ember/reactive/collections`?
253+
254+
Placing the collections in the main export surface alongside core primitives like `tracked`, `cached`, `cell`, and `resource` may not conflate importance of the collections.
255+
256+
> [!NOTE]
257+
> At the time of writing of this RFC, `tracked`, `cached`, `cell`, and `resource` RFCs have not been accepted for inclusion in `@ember/reactive`
258+
259+
This is motivated by actual usage out in the ecosystem of tracked-built-ins:
260+
261+
here are results from github.com searches for the `tracked-built-ins` equivalents (excluding ember-owned repos and forks of them):
262+
- "new TrackedObject(" - [520 Results]([https://github.com/search?q=%22new+TrackedObject%28%22&type=code](https://github.com/search?q=%22new+TrackedObject%28%22+NOT+is%3Afork++NOT+org%3Aemberjs+NOT+org%3Atracked-tools+NOT+org%3Aember-cli+NOT+org%3Aember-migration-utils+NOT+org%3Aember-learn&type=code))
263+
- "new TrackedArray(" - [312 Results](https://github.com/search?q=%22new+TrackedArray%28%22+NOT+is%3Afork++NOT+org%3Aemberjs+NOT+org%3Atracked-tools+NOT+org%3Aember-cli+NOT+org%3Aember-migration-utils+NOT+org%3Aember-learn+&type=code)
264+
- "new TrackedSet(" - [74 Results](https://github.com/search?q=%22new+TrackedSet%28%22+NOT+is%3Afork++NOT+org%3Aemberjs+NOT+org%3Atracked-tools+NOT+org%3Aember-cli+NOT+org%3Aember-migration-utils+NOT+org%3Aember-learn+&type=code)
265+
- "new TrackedWeakSet(" - [5 Results](https://github.com/search?q=%22new+TrackedWeakSet%28%22+NOT+is%3Afork++NOT+org%3Aemberjs+NOT+org%3Atracked-tools+NOT+org%3Aember-cli+NOT+org%3Aember-migration-utils+NOT+org%3Aember-learn+&type=code)
266+
- "new TrackedWeakMap(" - [4 Results](https://github.com/search?q=%22new+TrackedWeakMap%28%22+NOT+is%3Afork++NOT+org%3Aemberjs+NOT+org%3Atracked-tools+NOT+org%3Aember-cli+NOT+org%3Aember-migration-utils+NOT+org%3Aember-learn+&type=code)
267+
268+
Additionally, specifying collections gives us a blessed path for exported other useful datastructures in the future without continually adding to the main export file (even though dead-code-elimination would eliminate what is unused - not importing what may not be used could help local development)
251269

252270
### Consumption
253271

@@ -274,7 +292,7 @@ A utility for creating tracked arrays, copying the original data so that mutatio
274292
See [MDN for more information](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
275293

276294
```gjs
277-
import { trackedArray } from '@ember/reactive';
295+
import { trackedArray } from '@ember/reactive/collections';
278296
import { on } from '@ember/modifier';
279297
import { fn } from '@ember/helper';
280298
@@ -301,7 +319,7 @@ A utility for creating tracked objects, copying the original data so that mutati
301319
See [MDN for more information](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
302320

303321
```gjs
304-
import { trackedObject } from '@ember/reactive';
322+
import { trackedObject } from '@ember/reactive/collections';
305323
import { on } from '@ember/modifier';
306324
import { fn } from '@ember/helper';
307325
@@ -328,7 +346,7 @@ A utility for creating tracked maps, copying the original data so that mutations
328346
See [MDN for more information](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
329347

330348
```gjs
331-
import { trackedMap } from '@ember/reactive';
349+
import { trackedMap } from '@ember/reactive/collections';
332350
import { on } from '@ember/modifier';
333351
import { fn } from '@ember/helper';
334352
@@ -356,7 +374,7 @@ A utility for creating tracked weak maps, copying the original data so that muta
356374
See [MDN for more information](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap)
357375

358376
```gjs
359-
import { trackedWeakMap } from '@ember/reactive';
377+
import { trackedWeakMap } from '@ember/reactive/collections';
360378
import { on } from '@ember/modifier';
361379
import { fn } from '@ember/helper';
362380
@@ -380,7 +398,7 @@ A utility for creating tracked maps, copying the original data so that mutations
380398
See [MDN for more information](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
381399

382400
```gjs
383-
import { trackedSet } from '@ember/reactive';
401+
import { trackedSet } from '@ember/reactive/collections';
384402
import { on } from '@ember/modifier';
385403
import { fn } from '@ember/helper';
386404
@@ -408,7 +426,7 @@ A utility for creating tracked weak sets, copying the original data so that muta
408426
See [MDN for more information](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet)
409427

410428
```gjs
411-
import { trackedWeakSet } from '@ember/reactive';
429+
import { trackedWeakSet } from '@ember/reactive/collections';
412430
import { on } from '@ember/modifier';
413431
import { fn } from '@ember/helper';
414432
@@ -469,7 +487,7 @@ We should do a codemod to convert the newable constructors from tracked-built-in
469487
Using Vite or Webpack (Embroider 3+), we can alias `tracked-built-ins` to point at the new modules, using a shim -- for example:
470488
```js
471489
// app/built-ins-shim.js
472-
import { trackedArray } from '@ember/reactive';
490+
import { trackedArray } from '@ember/reactive/collections';
473491

474492
export class TrackedArray {
475493
constructor(arr) {

0 commit comments

Comments
 (0)