@johnunclesam wrote:
I need to understand once for all why property like
isSettledisPendingisFulfilledare different if I'm including or not the data in my API respone.
I'm asking here this: https://discuss.emberjs.com/t/ember-2-show-a-single-loading-message-when-the-ids-where-included-in-the-original-response/12654 which leads me to this strange behaviour:
If I include in my API responde the data (ex:
model.posts) these properties are immediately set to true (and.isPendingto false) also if Chrome is still loading the real data (also for the first time!).And this is a problem because I don't know if the posts[] are empty or not and I don't know what I can spy because something like that doesn't work:
{{#each model.posts}} My posts. {{else}} {{#if model.posts.isPending}} <div>Loading...</div> {{else}} <div>Nothing to show.</div> {{/if}} {{/each}}It's always "Nothing to show." until Chrome loads. Because
.isPendingis immediately false.Also if I use the length attributes:
{{#if (eq model.posts.length 0)}}because the starting posts[] array and the empty one is always to length == 0.
If I loads posts differently, async, not sideloaded (but with hundreds HTTP requests, which I don't want) it works. Ember recognize an
isPending...Why this strange behaviour?
Posts: 3
Participants: 2