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

Replace Ember.Map/OrderedSet with native Map/Set classes #5254

Closed
Turbo87 opened this issue Nov 9, 2017 · 6 comments
Closed

Replace Ember.Map/OrderedSet with native Map/Set classes #5254

Turbo87 opened this issue Nov 9, 2017 · 6 comments

Comments

@Turbo87
Copy link
Member

Turbo87 commented Nov 9, 2017

ember-data is currently using Ember.Map and Ember.OrderedSet, which are close approximations of the native Map and Set classes introduced in ES2015. It seems that ember-data is the only major user of these classes and Ember is not even using them itself anymore and would like to get rid of them.

Since 3.0 is around the corner it might make sense to reevaluate the usefulness of these polyfills as IE11 already has somewhat usable native Map and Set support (see http://kangax.github.io/compat-table/es6/#test-Map).

As some public methods of ember-data return instances of Map and MapWithDefault this would probably have to be considered a breaking change 🤔

@rwjblue
Copy link
Member

rwjblue commented Nov 9, 2017

I submitted #5255 to migrate away from Ember.Map and Ember.MapWithDefault (to native Map), however after discussing with @hjdivad I believe that we will still have a need for @ember/ordered-set (the addon) as a custom data store for the ember-data relationship data (e.g. an array like with fast membership lookup for large relationships).

@Turbo87
Copy link
Member Author

Turbo87 commented Nov 9, 2017

@rwjblue as mentioned in emberjs/ember-ordered-set#14 it seems that the differences between OrderedSet and Set are quite small, what is the specific difference that makes it necessary to keep OrderedSet around?

@hjdivad
Copy link
Member

hjdivad commented Nov 9, 2017

@Turbo87 https://github.com/emberjs/data/blob/master/addon/-private/system/ordered-set.js#L19

The order is not always insertion order. When inserting into a hasMany it is possible to insert at an arbitrary index. The relationships code currently assumes its set members has the same order as the many array.

@Turbo87
Copy link
Member Author

Turbo87 commented Nov 9, 2017

@hjdivad okay, so we are actually talking about EmberData.OrderedSet 😉

@Turbo87
Copy link
Member Author

Turbo87 commented Nov 9, 2017

this is somewhat important though because in that case the code for OrderedSet could just live inside of Ember Data instead of having a dedicated addon just for that class

@rwjblue
Copy link
Member

rwjblue commented Nov 9, 2017

@Turbo87 - Confirm, but I was just going to use the addon simply because it was already done and tested (thanks!). It also keeps the specific things needed here much simpler to reason about (e.g. the logic to avoid duplicating if Ember.OrderedSet is present).

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

No branches or pull requests

3 participants