abuiles / ember-cli-101-errata

18 stars 4 forks source link

DS.findAll returning "live" array vs promise #244

Open bambery opened 9 years ago

bambery commented 9 years ago

edition: 2015-07-20 format: kindle page: 2190(ish)

the text says "like peekAll and filter, the result from findAll is a live array".

According to the docs, what is returned from findAll (http://emberjs.com/api/data/classes/DS.Store.html#method_findAll) and from filter (http://emberjs.com/api/data/classes/DS.Store.html#method_filter) is actually a promise (or promise array). These will resolve into RecordArrays, like what is returned from peekAll, but different subclasses. Peek is specifically said not to return promises. It's slightly confusing to gloss over the promise part during this explanation, and the differences in the return classes.

The fact that promises are returned is mentioned later ("Unlike findRecord, query, or findAll, the behavior of this function [peekRecord] is synchronous"), but it was somewhat confusing while following along and also looking up doc during a first read-through.

It's also slightly confusing to use the term 'live array'. While it's descriptive in terms of concept, it's a descriptive term for RecordArray (right? This is what I'm understanding from the api doc?), the actual class name. It would be helpful to mention the actual class. The only time the word "live" is used in the doc is under the filter method.