Skip to content

Commit

Permalink
Records that could not be found can be retried
Browse files Browse the repository at this point in the history
Fixes #1235
  • Loading branch information
wycats committed Sep 6, 2013
1 parent 55eefca commit 63795a4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/ember-data/lib/system/model/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ DS.Model = Ember.Object.extend(Ember.Evented, {
this.send('loadedData');
},

notFound: function() {
this.send('notFound');
},

pushedData: function() {
this.send('pushedData');
},
Expand Down
4 changes: 4 additions & 0 deletions packages/ember-data/lib/system/model/states.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,10 @@ var RootState = {

becameError: function(record) {
record.triggerLater('becameError', record);
},

notFound: function(record) {
record.transitionTo('empty');
}
},

Expand Down
4 changes: 4 additions & 0 deletions packages/ember-data/lib/system/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -1381,6 +1381,10 @@ function _find(adapter, store, type, id, resolver) {
payload = serializer.extract(store, type, payload, id, 'find');

return store.push(type, payload);
}, function(error) {
var record = store.getById(type, id);
record.notFound();
throw error;
}).then(resolver.resolve, resolver.reject);
}

Expand Down

2 comments on commit 63795a4

@sly7-7
Copy link
Contributor

@sly7-7 sly7-7 commented on 63795a4 Nov 19, 2013

Choose a reason for hiding this comment

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

I think this is breaking the reload test. I don't know why this has not been seen since this time. In case of reloading and an error is thrown, then the record is in the loaded.saved state, and thus cannot handle the notFound event.

@bradleypriest
Copy link
Member

Choose a reason for hiding this comment

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

@sly7-7 there's currently two open issues and a PR on the matter, would love your help fixing

Please sign in to comment.