1

I use Ember data with the REST Adapter. I want to make sure that in case of slow server responses, the application does not fail.

I have simulated this bij adding at server side a sleep method of 5 seconds before returning the JSON response.

If you have a form with a SAVE button, and you click this button while a previous save is still is progress, you receive a inFlight error and the whole Ember app freezes (only thing you can do is reload app). So, you can easily disable the save button by checking the isSaving state:

<button {{action 'save'}} {{bindAttr disabled="isSaving"}}>Save</button>

Now it also seems that when changing a form field while a previous save is still is progress, you receive a inFlight error. This would thus indicate that I also need to disable the complete form.

Uncaught Error: Attempted to handle event `willSetProperty` on 
<App.Author:ember477:5203e34599808d1c6c000001> while in state 
rootState.loaded.updated.inFlight. Called with {reference: [object Object], store: 
<App.Store:ember541>, name: name} 

Is there a known good practice to handle these cases ... I want to prevent that I need to add a lot of logic (disable buttons, set fields readonly, etc.) for these edge cases.

intuitivepixel
  • 23,302
  • 3
  • 57
  • 51
cyclomarc
  • 1,992
  • 1
  • 24
  • 54

1 Answers1

2

It may not be within the scope of what you are trying to do, but the Ember Persistence Foundation is designed to allow updating your models while a save is still in flight.

It is relatively trivial to migrate your models to EPF, but there are some changes required in the controller code, see "Migrating from Ember Data".

kibibu
  • 6,115
  • 1
  • 35
  • 41
  • 1
    Might indeed be an alternative, but switching to an other library for handling all data interaction is not something you do overnight ... Most probably, EPF has also limitations and at first sight, their documentation and the samples that you find are even more limited/restricted compared to Ember data. – cyclomarc Aug 09 '13 at 07:40