This repository has been archived by the owner on Mar 22, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2741 from HeroicEric/ember-data-deprecation-guide
Add ember-data deprecation guide
- Loading branch information
Showing
2 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
}) | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters