Skip to content

Implement trackedObject, trackedSet, trackedWeakSet, trackedMap, and trackedWeakMap #1748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

NullVoxPopuli
Copy link
Contributor

@NullVoxPopuli NullVoxPopuli commented Apr 30, 2025

RFC: emberjs/rfcs#1068

Followup to: #1713

Changes from the tracked-built-ins implementation (as described by the RFC)

  • use tags directly, don't use cache / tracked-storage apis (these don't exist anyway)
  • defaults to Object.is for the equals function
    • this means that equality / dirty checking is value-based by default, rather than every assignment causing a dirty
  • has overridable equals function
    • to get tracked-built-ins behavior back, you set equals: () => false
      example:
      class TrackedArray {
        constructor(input) {
          return trackedArray(input, { equals: () => false });
        }
      }
  • description is currently unused, but @wycats has plans -- description is meant for debugger hints

Progress:

  • trackedWeakSet
  • trackedWeakMap
  • trackedSet
  • trackedMap
  • trackedObject

Tasks for self-review

  • all collections have some expectType tests
  • if there is an iterator, make sure that setting a value
    • does NOT dirty the collection if the key was pre-existing
    • DOES dirty the collection if the key was not pre-existing
  • tests for specifying equals
  • fix the array implementation / compare with Vue's version: https://github.com/vuejs/core/blob/main/packages/reactivity/src/arrayInstrumentations.ts
    (this is mainly because the version of trackedArray we have (from tracked-built-ins) doesn't pass all our tests -- so I need to compare with someone else's implementation to see what's different)

Copy link
Contributor

github-actions bot commented Apr 30, 2025

This PRmain
Dev
602K └─┬ .
169K   ├── runtime
160K   ├── syntax
100K   ├── compiler
 58K   ├── opcode-compiler
 38K   ├── validator
 27K   ├── manager
 11K   ├── program
8.9K   ├── reference
7.2K   ├── destroyable
6.3K   ├── util
4.3K   ├── node
3.4K   ├── global-context
2.5K   ├── wire-format
1.0K   ├── vm
969B   ├── encoder
844B   ├── vm-babel-plugins
606B   └── owner
588K └─┬ .
169K   ├── runtime
160K   ├── syntax
100K   ├── compiler
 58K   ├── opcode-compiler
 27K   ├── manager
 24K   ├── validator
 11K   ├── program
8.9K   ├── reference
7.2K   ├── destroyable
6.3K   ├── util
4.3K   ├── node
3.4K   ├── global-context
2.5K   ├── wire-format
1.0K   ├── vm
969B   ├── encoder
844B   ├── vm-babel-plugins
606B   └── owner
Prod
 236K └─┬ .
  70K   ├── syntax
  63K   ├── runtime
  48K   ├── compiler
  18K   ├── opcode-compiler
10.0K   ├── validator
 7.9K   ├── manager
 4.8K   ├── program
 3.6K   ├── reference
 2.4K   ├── util
 2.1K   ├── node
 1.6K   ├── wire-format
 1.5K   ├── destroyable
 737B   ├── vm
 594B   ├── global-context
 516B   ├── encoder
 469B   ├── vm-babel-plugins
 155B   └── owner
231K └─┬ .
 70K   ├── syntax
 63K   ├── runtime
 48K   ├── compiler
 18K   ├── opcode-compiler
7.9K   ├── manager
5.1K   ├── validator
4.8K   ├── program
3.6K   ├── reference
2.4K   ├── util
2.1K   ├── node
1.6K   ├── wire-format
1.5K   ├── destroyable
737B   ├── vm
594B   ├── global-context
516B   ├── encoder
469B   ├── vm-babel-plugins
155B   └── owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant