|
| 1 | +--- |
| 2 | +stage: accepted |
| 3 | +start-date: 2023-12-22T00:00:00.000Z |
| 4 | +release-date: # In format YYYY-MM-DDT00:00:00.000Z |
| 5 | +release-versions: |
| 6 | +teams: # delete teams that aren't relevant |
| 7 | + - framework |
| 8 | + - learning |
| 9 | + - typescript |
| 10 | +prs: |
| 11 | + accepted: https://github.com/emberjs/rfcs/pull/1000 |
| 12 | +project-link: |
| 13 | +suite: |
| 14 | +--- |
| 15 | + |
| 16 | +<!--- |
| 17 | +Directions for above: |
| 18 | +
|
| 19 | +stage: Leave as is |
| 20 | +start-date: Fill in with today's date, 2032-12-01T00:00:00.000Z |
| 21 | +release-date: Leave as is |
| 22 | +release-versions: Leave as is |
| 23 | +teams: Include only the [team(s)](README.md#relevant-teams) for which this RFC applies |
| 24 | +prs: |
| 25 | + accepted: Fill this in with the URL for the Proposal RFC PR |
| 26 | +project-link: Leave as is |
| 27 | +suite: Leave as is |
| 28 | +--> |
| 29 | + |
| 30 | +# Make `(array)` a built in helper |
| 31 | + |
| 32 | +## Summary |
| 33 | + |
| 34 | +Today, when using gjs/gts/`<template>`, in order make arrays in templates, folks _must import_ the `(array)` helper. |
| 35 | +Because creating arrays is fairly commonplace, this is an annoyance for developers, in part, due to how almost every other language has array literal syntax. |
| 36 | + |
| 37 | +This RFC proposes that `(array)` be built in to `glimmer-vm` and not require importing. |
| 38 | + |
| 39 | +## Motivation |
| 40 | + |
| 41 | +Arrays and Objects are not only very common to create, they are essential tools when yielding data out of components. |
| 42 | + |
| 43 | +There is alternate motivation to implement _literals_ for arrays and objects, but that is a bigger can of worms for another time. |
| 44 | + |
| 45 | +## Detailed design |
| 46 | + |
| 47 | +This change would affect strict-mode only. This is so that today's existing code that imports `array` from `@ember/helper` will still work due to how values defined locally in scope override globals. |
| 48 | + |
| 49 | +The behavior of `array` would be the same as it is today, but defined by default in the `glimmer-vm`. |
| 50 | + |
| 51 | +Being built in can give folks confidence that each element in the array is individually reactive. |
| 52 | + |
| 53 | +## How we teach this |
| 54 | + |
| 55 | +Once implemented, the guides, if they say anything about gjs/gts/`<template>` and `array` by the time this would be implemented, would only remove the import. |
| 56 | + |
| 57 | +The guides should also detail which functions are built in to the framework and, therefore, do not need to be imported. |
| 58 | + |
| 59 | +## Drawbacks |
| 60 | + |
| 61 | +People may not know where `array` is defined. |
| 62 | +- counterpoint: do they need to? |
| 63 | + |
| 64 | +## Alternatives |
| 65 | + |
| 66 | +n/a |
| 67 | + |
| 68 | +## Unresolved questions |
| 69 | + |
| 70 | +n/a |
0 commit comments