Skip to content
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

Tracked storage implementations #161

Merged
merged 16 commits into from
Oct 26, 2021

Conversation

NullVoxPopuli
Copy link
Collaborator

@NullVoxPopuli NullVoxPopuli commented Sep 11, 2021

This PR requires: #160 be merged first

  • requires Ember 3.23+
  • upgrades to tracked-maps-and-sets@v3
  • drops support for Node 8 (wasn't tested against anyway)
  • deletes legacy implementation / code

return createArrayProxy(arr.slice());
let clone = arr.slice();
// eslint-disable-next-line @typescript-eslint/no-this-alias
let self = this;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using this blast from the past because not all of the proxy hooks have a receiver? or at least my editor didn't say that they did.

If I'm wrong, I'll gladly swap out all the self references to receiver.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, for the array case they all do - because the only hooks needed are get and set. So there you can use receiver. But for the object case you're right.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually no, you can't use receiver as it's the Proxy object, not the instance of the class that has the needed methods.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's why let self = this 🙃

@NullVoxPopuli
Copy link
Collaborator Author

@chriskrycho / @pzuraq these are the failing tests atm, but do these failing tests imply that we need to fix something in tracked-maps-and-sets?
image

once resolved, I think this is ready to go?

@boris-petrov
Copy link

@NullVoxPopuli - are you sure tracked-maps-and-sets is needed at all after the changes in this PR?

@NullVoxPopuli
Copy link
Collaborator Author

Yeah, this library re-exports maps and sets, and uses them in the decorator

@chriskrycho
Copy link
Collaborator

I will try to dig into this PR tomorrow (very full day today!), but at a first pass without even having looked at it, I'd say:

  1. Yeah, we definitely want those to pass!
  2. Therefore, we should check and make sure they pass upstream in tracked-maps-and-sets – I think we have coverage of this same behavior there, but don't recall 100% off the top of my head.
  3. If they do pass upstream and don't pass here, it means the decorator implementation is doing the wrong thing.

@NullVoxPopuli
Copy link
Collaborator Author

  1. Excellent :D
  2. Fix incorrect prototype chain to make instanceof work tracked-maps-and-sets#137
  3. they do not pass. :D which is great, because it means I didn't do anything totally dumb while mindlessly doing this PR 🙃

@chriskrycho chriskrycho added breaking enhancement New feature or request labels Sep 14, 2021
let index = convertToInt(prop);

if (index !== null) {
self.storageFor(index);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NullVoxPopuli - shouldn't this be self.readStorageFor(index) (like in tracked-object)? And readStorageFor should also be changed to getValue(storage) instead of return storage. Or am I missing something?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's been a minute, but I think it's just a method naming inconsistency?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, check the similar method in object.ts. It does getValue(storage) (which in the array case it doesn't do).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it does for the collection reference

@boris-petrov
Copy link

boris-petrov commented Oct 5, 2021

Now the implementation looks correct, thanks! A couple of notes:

  1. instead of using // @private in object.ts you could do the same as in array.ts - use the private keyword.

  2. storages = new Map(); in object.ts could be updated to match array.ts - i.e. have a better type-signature.

  3. it's a pity that the tests didn't catch the lack of getValue(storage); in readStorageFor. If you have the time, you might add some to catch that case.

P.S.

  1. oh, and the linting doesn't pass. 😄

@NullVoxPopuli
Copy link
Collaborator Author

I'll take a look as soon as tracked-maps-and-sets is released as that is a dependency for this work to move forward

@chriskrycho
Copy link
Collaborator

@NullVoxPopuli I've released tracked-maps-and-sets v3.0.2, which should unblock this! You'll need to basically run CI locally (or on your own fork) at present, though, as there's something blocking GH Actions on the newly-created org here (I've filed a ticket with GH support, but it's unclear how long it will take to get resolved). Note that this is also a prerequisite for #173. 😩 Lots of pieces in flight here. Let me know when you've rebased and I'll review!

@chriskrycho
Copy link
Collaborator

@NullVoxPopuli @SergeAstapov if need be I can basically fold these two PRs together.

@NullVoxPopuli NullVoxPopuli marked this pull request as ready for review October 26, 2021 00:09
@NullVoxPopuli
Copy link
Collaborator Author

Locally,

  • all pass -- yarn lint
    • template
    • eslint
    • tsc
  • mixed passing -- yarn test
    • standardo
    • try scenarios
      • passing:
        • release
        • 3.24
      • failing (epected) (needs ember-auto-import@v2 in devDeps):
        • canary
        • beta
      • failed, needs investigation - not supported? 3.20 support will be dropped (by ember) when 3.28 becomes LTS, yeah?
        • 3.20 fails the {{each}} / {{each-in}} tests
  • yarn prepublishOnly (because of the secret incantation -- it is not the same as lint:tsc`)

Copy link
Collaborator

@chriskrycho chriskrycho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall 👍🏻 – bunch of tweaks around privacy, but that's it!

README.md Outdated Show resolved Hide resolved
* Ember CLI v2.13 or above
* Node.js v8 or above
* Ember.js v3.23 or above
* Ember CLI v3.23 or above
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it actually require a CLI bump? I'd prefer to just leave CLI alone unless there's a reason to change it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably not!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but, we aren't testing against ember-cli 2.13

README.md Outdated Show resolved Hide resolved
addon/-private/array.ts Outdated Show resolved Hide resolved
addon/-private/array.ts Outdated Show resolved Hide resolved
addon/-private/object.js Outdated Show resolved Hide resolved
addon/-private/array.ts Outdated Show resolved Hide resolved
addon/-private/array.ts Outdated Show resolved Hide resolved
addon/-private/array.ts Outdated Show resolved Hide resolved
addon/-private/array.ts Outdated Show resolved Hide resolved
NullVoxPopuli and others added 3 commits October 26, 2021 12:11
Co-authored-by: Chris Krycho <hello@chriskrycho.com>
Co-authored-by: Chris Krycho <hello@chriskrycho.com>
Co-authored-by: Chris Krycho <hello@chriskrycho.com>
NullVoxPopuli and others added 5 commits October 26, 2021 12:12
Co-authored-by: Chris Krycho <hello@chriskrycho.com>
Co-authored-by: Chris Krycho <hello@chriskrycho.com>
Co-authored-by: Chris Krycho <hello@chriskrycho.com>
Co-authored-by: Chris Krycho <hello@chriskrycho.com>
Copy link
Collaborator

@chriskrycho chriskrycho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran CI locally:

------ RESULTS ------

Scenario ember-lts-3.24: SUCCESS
Command run: ember test
┌────────────────────┬────────────────────┬──────────────────────────────┬──────────┐
│ Dependency         │ Expected           │ Used                         │ Type     │
├────────────────────┼────────────────────┼──────────────────────────────┼──────────┤
│ ember-source       │ 3.24.3             │ 3.24.3                       │ yarn     │
└────────────────────┴────────────────────┴──────────────────────────────┴──────────┘

Scenario ember-lts-3.28: SUCCESS
Command run: ember test
┌────────────────────┬────────────────────┬──────────────────────────────┬──────────┐
│ Dependency         │ Expected           │ Used                         │ Type     │
├────────────────────┼────────────────────┼──────────────────────────────┼──────────┤
│ ember-source       │ ~3.28.0            │ 3.28.4                       │ yarn     │
└────────────────────┴────────────────────┴──────────────────────────────┴──────────┘

Scenario ember-release: SUCCESS
Command run: ember test
┌────────────────────┬────────────────────┬──────────────────────────────┬──────────┐
│ Dependency         │ Expected           │ Used                         │ Type     │
├────────────────────┼────────────────────┼──────────────────────────────┼──────────┤
│ ember-source       │ https://s3.amazon… │ 3.28.4-release+62976fe7      │ yarn     │
└────────────────────┴────────────────────┴──────────────────────────────┴──────────┘

Scenario ember-beta: FAIL
Command run: ember test
┌────────────────────┬────────────────────┬──────────────────────────────┬──────────┐
│ Dependency         │ Expected           │ Used                         │ Type     │
├────────────────────┼────────────────────┼──────────────────────────────┼──────────┤
│ ember-source       │ https://s3.amazon… │ 4.0.0-beta.5.beta+829c1131   │ yarn     │
└────────────────────┴────────────────────┴──────────────────────────────┴──────────┘

Scenario ember-canary: FAIL
Command run: ember test
┌────────────────────┬────────────────────┬──────────────────────────────┬──────────┐
│ Dependency         │ Expected           │ Used                         │ Type     │
├────────────────────┼────────────────────┼──────────────────────────────┼──────────┤
│ ember-source       │ https://s3.amazon… │ 4.1.0-alpha.2.canary+67d465… │ yarn     │
└────────────────────┴────────────────────┴──────────────────────────────┴──────────┘


2 scenarios failed
3 scenarios succeeded
5 scenarios run

This is as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants