Skip to content

Commit

Permalink
Updates imports in documentation to adhere to RFC 176
Browse files Browse the repository at this point in the history
  • Loading branch information
locks committed Jul 31, 2017
1 parent d35feb1 commit 87b7652
Show file tree
Hide file tree
Showing 9 changed files with 317 additions and 279 deletions.
20 changes: 10 additions & 10 deletions addon/-private/adapters/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ const PRIMARY_ATTRIBUTE_KEY = 'base';
`under-maintenance` route:
```app/routes/application.js
import Ember from 'ember';
import Route from '@ember/routing/route';
import MaintenanceError from '../adapters/maintenance-error';
export default Ember.Route.extend({
export default Route.extend({
actions: {
error(error, transition) {
if (error instanceof MaintenanceError) {
Expand Down Expand Up @@ -148,13 +148,13 @@ if (extendedErrorsEnabled) {
rejects with a `DS.InvalidError` object that looks like this:
```app/adapters/post.js
import Ember from 'ember';
import RSVP from 'rsvp';
import DS from 'ember-data';
export default DS.RESTAdapter.extend({
updateRecord() {
// Fictional adapter that always rejects
return Ember.RSVP.reject(new DS.InvalidError([
return RSVP.reject(new DS.InvalidError([
{
detail: 'Must be unique',
source: { pointer: '/data/attributes/title' }
Expand Down Expand Up @@ -189,12 +189,12 @@ export const InvalidError = extend(AdapterError,
connection if an adapter operation has timed out:
```app/routes/application.js
import Ember from 'ember';
import Route from '@ember/routing/route';
import DS from 'ember-data';
const { TimeoutError } = DS;
export default Ember.Route.extend({
export default Route.extend({
actions: {
error(error, transition) {
if (error instanceof TimeoutError) {
Expand Down Expand Up @@ -237,12 +237,12 @@ export const AbortError = extend(AdapterError,
request is unauthorized:
```app/routes/application.js
import Ember from 'ember';
import Route from '@ember/routing/route';
import DS from 'ember-data';
const { UnauthorizedError } = DS;
export default Ember.Route.extend({
export default Route.extend({
actions: {
error(error, transition) {
if (error instanceof UnauthorizedError) {
Expand Down Expand Up @@ -285,12 +285,12 @@ export const ForbiddenError = extendedErrorsEnabled ?
for a specific model that does not exist. For example:
```app/routes/post.js
import Ember from 'ember';
import Route from '@ember/routing/route';
import DS from 'ember-data';
const { NotFoundError } = DS;
export default Ember.Route.extend({
export default Route.extend({
model(params) {
return this.get('store').findRecord('post', params.post_id);
},
Expand Down
46 changes: 24 additions & 22 deletions addon/-private/system/model/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,16 +289,17 @@ export default Ember.ArrayProxy.extend(Ember.Evented, {
```
```app/routes/user/edit.js
import Ember from 'ember';
import Route from '@ember/routing/route';
export default Ember.Route.extend({
export default Route.extend({
actions: {
save: function(user) {
if (!user.get('twoFactorAuth')) {
user.get('errors').remove('phone');
}
user.save();
}
save(user) {
if (!user.get('twoFactorAuth')) {
user.get('errors').remove('phone');
}
user.save();
}
}
});
```
Expand Down Expand Up @@ -344,14 +345,14 @@ export default Ember.ArrayProxy.extend(Ember.Evented, {
Example:
```app/routes/user/edit.js
import Ember from 'ember';
import Route from '@ember/routing/route';
export default Ember.Route.extend({
export default Route.extend({
actions: {
retrySave: function(user) {
user.get('errors').clear();
user.save();
}
retrySave(user) {
user.get('errors').clear();
user.save();
}
}
});
```
Expand Down Expand Up @@ -401,16 +402,17 @@ export default Ember.ArrayProxy.extend(Ember.Evented, {
Checks if there is error messages for the given attribute.
```app/routes/user/edit.js
import Ember from 'ember';
import Route from '@ember/routing/route';
export default Ember.Route.extend({
export default Route.extend({
actions: {
save: function(user) {
if (user.get('errors').has('email')) {
return alert('Please update your email before attempting to save.');
}
user.save();
}
save(user) {
if (user.get('errors').has('email')) {
return alert('Please update your email before attempting to save.');
}
user.save();
}
}
});
```
Expand Down
Loading

0 comments on commit 87b7652

Please sign in to comment.