-
-
Notifications
You must be signed in to change notification settings - Fork 408
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
[DEPRECATION RFC ember-data] deprecate errors changing record state #384
Closed
runspired
wants to merge
3
commits into
emberjs:master
from
runspired:ember-data-errors-manipulation-deprecation
Closed
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
text/0000-ember-data-deprecate-errors-changing-valid-state.md
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,65 @@ | ||
- Start Date: 2018-10-04 | ||
- RFC PR: (leave this empty) | ||
- Ember Issue: (leave this empty) | ||
|
||
# Ember Data | Deprecate Errors changing record-state | ||
|
||
## Summary | ||
|
||
Deprecates the `add` `remove` and `clear` methods of `DS.Errors` in favor of `addError` | ||
`removeError` and `clearErrors`. | ||
|
||
## Motivation | ||
|
||
In `ember-data`, adding, removing, or clearing errors from a record's `errors` object | ||
will affect the validation state of the record. Previously a [soft-deprecation](https://github.com/emberjs/data/pull/3853) of | ||
this behavior was added; however, it provided no clear path to resolution. | ||
|
||
By deprecating these methods entirely, and providing replacement methods that do not | ||
affect the state of the `record`, we provide end users a clear path and a clear timeline | ||
for resolving the deprecation, and a mechanism through which users can determine if this | ||
change in behavior requires any additional changes in their application code. | ||
|
||
## Detailed design | ||
|
||
The warnings in `DS.Errors` `add` `remove` and `clear` will be upgraded to deprecations | ||
targeting the next LTS `3.8`. This means the feature and these methods will be removed | ||
in `3.9`. | ||
|
||
New methods will be added to `DS.Errors` that do not affect record state. `addErrors` `removeErrors` | ||
and `clearErrors`. These methods will have the same signatures as before, listed below, where | ||
`member` is one of `type` `id` or the property name of an `attribute` or `relationship`. | ||
|
||
```typescript | ||
interface Errors { | ||
addErrors(member: string, messages: string|Array<string>): void; | ||
removeErrors(member: string): void; | ||
clearErrors(): void; | ||
} | ||
``` | ||
|
||
## How we teach this | ||
|
||
`DS.Errors` is not well documented today, so this is an opportunity for us to revisit and | ||
clean up. | ||
|
||
## Drawbacks | ||
|
||
- For apps using `Errors` that do not rely on the changes to record state, this will feel like | ||
unnecessary churn. | ||
- The new method names may feel unnecessarily verbose | ||
|
||
## Alternatives | ||
|
||
Two alternatives were considered: | ||
|
||
1) upgrading the existing warning to specify that the behavior would be removed in `3.9`, | ||
We felt this was equally un-actionable as the state of things today. | ||
2) treating the warning as a fully complete deprecation, and removing the undesired behavior now, | ||
as the warning has been in place long enough to be considered "complete" post the `3.4 lts` cycle. | ||
We felt this was unfair to consumers who have had no way to act upon the deprecation or determine | ||
if it would have any effects on their applications. | ||
|
||
## Unresolved questions | ||
|
||
None |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This uses the singular whereas the design uses the plural.