vendredi 14 octobre 2016

Cracking open results returned by Ember peekAll

I'm playing around with peekAll(), trying to understand how it works for the ultimate purpose of iterating through the results.

In a route's model hook, I have:

var peekAllResults = this.store.peekAll('position');
console.log("peekAllResults = ", peekAllResults);
var peekAllResultsContent = peekAllResults.get('content');
console.log("peekAlLresultsContent = ", peekAllResultsContent);

This is returning data, as expected based on what I've got in my app.

In particular, here's what shows in the console:

enter image description here

So far so good. There are 8 records as expected based on what I've got going on.

But when when I add:

console.log("peekAllResultsContent.length=", peekAllResultsContent.length)

I get: peekAllResultsContent.length = 0

Same thing if I do peekAllResultsContent.get("length")

What is going on there?

I thought peekAll was a synchronous call that returned an array. Is there some trick to cracking it open and seeing what's actually in the array? I can't even get the length, so I figure I'm not on the right track.




Aucun commentaire:

Enregistrer un commentaire