Skip to content

Use Ember Data decorators without parens where possible (#669) - #1063

Merged
chancancode merged 1 commit into
ember-learn:octanefrom
bertdeblock:improve-ember-data-decorator-usage-examples
Sep 30, 2019
Merged

chancancode merged 1 commit into
ember-learn:octanefrom
bertdeblock:improve-ember-data-decorator-usage-examples

Conversation

@bertdeblock

Copy link
Copy Markdown
Contributor

No description provided.

relationships. This could result in a potentially large amount of unnecessary
code. You can access these objects in the template without transforming them. This can be
done with `attr()` (No attribute type).
done with `@attr` (No attribute type).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Wouldn't it be better to write No transform specified instead of No attribute type? Not part of this PR though.

@jenweber

Copy link
Copy Markdown
Contributor

I have tried this on the latest version of an Octane app, and it appears that the () is still needed. Can you double check this?

If I do the following, I get Error while processing route: index "title" is read-only

import DS from 'ember-data';
const { Model, attr } = DS;

export default class SomeModelModel extends Model {
  @attr title;
}
import Route from '@ember/routing/route';

export default class ApplicationRoute extends Route {
  model() {
    this.store.createRecord('someModel', {title: 'yo'})
  }
}

@chancancode

Copy link
Copy Markdown
Contributor

Yes. This only works in ember data canary. Technically it has been merged into the beta branch too but there has not been a new beta release since. By the time of release (tomorrow?) it will work on both 3.13 stable and 3.14 beta.

@jenweber
jenweber self-requested a review September 16, 2019 21:54
@jenweber

Copy link
Copy Markdown
Contributor

Ok, thanks for the context! Let's merge this once that release is out.

@chancancode
chancancode merged commit 619b272 into ember-learn:octane Sep 30, 2019
@chancancode

Copy link
Copy Markdown
Contributor

Thanks @bertdeblock!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants