mardi 12 juin 2018

Ember Substates with Ember data after store already has data

I have read Ember docs related to Substates etc and I understand how it works. In my current application my loading.hbs and other child loading.hbs templates work fine.

I just want to discuss a use case.

  1. In my route A, in my model function I do fetchAll for my model.
  2. I go to Route A, First time api request is sent and I see my loading screen.
  3. now I navigate to some other route B.
  4. now I come back to first route A, api request is sent again but this time loading screen is not shown.

I want to develop my understanding here. Now the second time loading screen is not shown which tells us that store had data so there is no sense to put it on loading and after fetch store sent request to sync with backend.

QUESTION

Now I want to know if this is a default behaviour of Ember with Ember-data?

To show this loading screen, will I have to do something manually?

Ideally what I want is, if on second request data was fetched then show it and at the same time show loader to tell user that it is syncing with backend as well.

I know everything can be done manually, I don't want to reinvent the wheel or do things in non-conventional way. So I want to know best optimized solution for this as provided by Ember which an experienced Ember developer can help me understand.

Thanks in advance.




Aucun commentaire:

Enregistrer un commentaire