Skip to content
This repository has been archived by the owner on Mar 22, 2019. It is now read-only.

Commit

Permalink
Merge pull request #2741 from HeroicEric/ember-data-deprecation-guide
Browse files Browse the repository at this point in the history
Add ember-data deprecation guide
  • Loading branch information
locks committed Dec 5, 2016
2 parents 98f7c48 + c35bf98 commit b296470
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
35 changes: 35 additions & 0 deletions source/deprecations/ember-data/v2.x.html.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
title: Deprecations for Ember Data v2.x
alias: guides/deprecations/
layout: deprecations
---

## Deprecations Added in Ember Data 2.x

### Deprecations Added in Ember Data 2.3

#### Non-primitive defaultValue for Model Attributes

###### until: 3.0.0
###### id: ds.defaultValue.complex-object

Providing a non-primitive value as a `defaultValue` has been deprecated because
the provided value is shared between all instances of the model. Using a
non-primitive value, such as `defaultValue: []`, can lead to unexpected bugs when
that value is mutated.

If you wish to continue using a non-primitive value as the `defaultValue` for an
attribute, you should provide a function that returns the value:

```javascript
import DS from 'ember-data';

export default DS.Model.extend({
username: DS.attr('string'),
createdAt: DS.attr('date', {
defaultValue() {
return new Date();
}
})
});
```
6 changes: 5 additions & 1 deletion source/deprecations/index.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ code firing such deprecations is still supported by the Ember community. After
the next major revision lands, the supporting code may be removed. This style
of change management is commonly referred to as [Semantic Versioning](http://semver.org/).

### By Version
### Ember

* [Version 1.x](/deprecations/v1.x)
* [Version 2.x](/deprecations/v2.x)

### Ember Data

* [Version 2.x](/deprecations/ember-data/v2.x)

0 comments on commit b296470

Please sign in to comment.