-
Notifications
You must be signed in to change notification settings - Fork 163
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rename store and adapter for Ember Data compatibility #454
Conversation
271e098
to
2f25707
Compare
@nolaneo perhaps you could outline the ways in which this is breaking so that we can consider what might be the best path forward? |
dd20b23
to
99fc2a4
Compare
99fc2a4
to
a97841e
Compare
In the current release of Ember Model, you create and query records directly through the store by using For example let user = this.store.createRecord('user', {name: "Eoin"});
...
let user = this.store.find('user', 1).then(() => ...); This clashes with Ember Data's usage of With this proposed change, you would be required to rename any existing calls to the Ember Model store with the updated naming. The above example would become let user = this.emstore.createRecord('user', {name: "Eoin"});
...
let user = this.emstore.find('user', 1).then(() => ...);
...
// Which then allows us to do something like:
let emberDataModel = this.store.createRecord('my-ember-data-model', { ... }); |
Thanks. If we'd like to avoid breaking compatibility, we could possibly make the name of the store configurable with a default of Another option might be to run the ember-model initializer after the ember-data intializer and use a name of |
First off, thanks @GavinJoyce Big thumbs up on this PR as a way to migrate off of ember-model to ember-data. We will be pushing this to a production environment in the coming weeks. |
One breaking change that may not be obvious from this change is if a user is relying on Ember Route's to automatically find a record when the param follows the pattern Example: Router.map(function() {
this.route('photos', function(){
this.route('edit', { path: '/:photo_id' });
});
}); {{#link-to "photos.edit" 1}} // photos.edit route
export default Ember.Route.extend({
// This method does not need to be defined since Ember will do this automagically.
// In practice relying on this behavior is outdated but it still may be used by some older Ember Apps
model(params) {
return this.store.find('photo', params.photo_id)
}
}) |
application.register('store:main', store); | ||
var emstore = application.Store || Ember.Model.Store; | ||
application.register('emstore:application', emstore); | ||
application.register('emstore:main', emstore); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not to discourage this change just for information purposes, as of 2.0.0 Ember Data no longer registers anything on store:main
or store:application
instead Ember Data registers its store to service:store
.
Closing in favour of #474. I'm going to see if we can land this soon |
@intercom we're using both Ember Model and Ember Data in production. We're in the process of migrating fully to Ember Data. While that migration is happening, we have renamed the Ember Model store and data adapter to allow us to use both addons simultaneously as they conflict otherwise.
In this PR we've renamed
store
toemstore
anddata-adapter
toem-data-adapter
.@ebryn This is a breaking change, but it might be something for you to consider. It opens a path for people to move to Ember Data without having to rewrite all their models at once. Let me know your thoughts. 馃檪