dagda1
dagda1

Reputation: 28820

Ember data, how to get dispose of models in isError state

If I try and persist a model to a backend API and it fails, the model record is still in the store.

E.g.

todo.one 'becameError', (result)  ->
  #result.get('isError') == true

If I do a call to App.Todo.all(), the todo that failed is in the store and will appear in the app unless I filter out objects that have an isError state.

Is there a way I can dispose of the object when it is in this state?

I cannot call deleteRecord because there is an assertion stopping it being called for models that are an in an isError state.

Upvotes: 0

Views: 177

Answers (1)

intuitivepixel
intuitivepixel

Reputation: 23322

Why not call rollback on the record that failed to be saved, updated or deleted? So you would at least have a clean record to retry your operation.

For example:

todo.one 'becameError', (result)  ->
  result.get('transaction').rollback();

Hope it helps.

Upvotes: 1

Related Questions