Skip to content

Commit

Permalink
Improves omitMaterializing support with objectAt
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasbadia committed Aug 25, 2019
1 parent a65ae98 commit 86532c6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions frameworks/core_foundation/controllers/array.js
Expand Up @@ -285,9 +285,9 @@ SC.ArrayController = SC.Controller.extend(SC.Array, SC.SelectionSupport,
/** @private
Returns the object at the specified index based on the observable content
*/
objectAt: function (idx) {
objectAt: function (idx, omitMaterializing) {
var content = this._scac_observableContent();
return content ? content.objectAt(idx) : undefined;
return content ? content.objectAt(idx, omitMaterializing) : undefined;
},

/** @private
Expand Down
6 changes: 4 additions & 2 deletions frameworks/datastore/system/record_array.js
Expand Up @@ -197,9 +197,10 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,
records.
@param {Number} idx index of the object
@param {Boolean} omitMaterializing
@return {SC.Record} materialized record
*/
objectAt: function(idx) {
objectAt: function(idx, omitMaterializing) {

this.flush(); // cleanup pending if needed

Expand All @@ -213,12 +214,13 @@ SC.RecordArray = SC.Object.extend(SC.Enumerable, SC.Array,

// not in cache, materialize
if (!recs) this._scra_records = recs = [] ; // create cache
storeKey = storeKeys.objectAt(idx);
storeKey = storeKeys.objectAt(idx, omitMaterializing);

if (storeKey) {
// if record is not loaded already, then ask the data source to
// retrieve it
if (store.peekStatus(storeKey) === SC.Record.EMPTY) {
if (omitMaterializing) return undefined;
store.retrieveRecord(null, null, storeKey);
}
recs[idx] = ret = store.materializeRecord(storeKey);
Expand Down

0 comments on commit 86532c6

Please sign in to comment.