-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleanup record array manager #4597
Conversation
f3228b7
to
db29f12
Compare
|
||
test('stores the metadata off the payload', function(assert) { | ||
let recordArray = store.recordArrayManager | ||
.createAdapterPopulatedRecordArray(store.modelFor('person'), null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can re-use Person
like we do 2 tests below.
|
||
assert.throws(() => { | ||
recordArray.replace(); | ||
}, Error('The result of a server query (on (subclass of DS.Model)) is immutable.'), 'throws error'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're overwriting toString()
in the Person
above. Not sure why it's used here though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect the assertion to be 'The result of a server query (on Person) is immutable.'
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opened issue: #4615
function assertRecordHasRecordArray(assert, record, recordArray) { | ||
if (!assert) { throw TypeError('assertRecordHasRecordArray first argument must be QUnit\'s assert'); } | ||
if (!record) { throw TypeError('assertRecordHasRecordArray second argument must be a record'); } | ||
if (!assert) { throw TypeError('assertRecordHasRecordArray third argument must be a recordArray'); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/assert/recordArray/
function assertRecordDoesNOTRecordArray(assert, record, recordArray) { | ||
if (!assert) { throw TypeError('assertRecordHasRecordArray first argument must be QUnit\'s assert'); } | ||
if (!record) { throw TypeError('assertRecordHasRecordArray second argument must be a record'); } | ||
if (!assert) { throw TypeError('assertRecordHasRecordArray third argument must be a recordArray'); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mhmm lecker, copy pasta 🍜
@@ -73,15 +76,19 @@ export default RecordArray.extend({ | |||
*/ | |||
loadRecords(internalModels, payload) { | |||
let token = heimdall.start('AdapterPopulatedRecordArray.loadRecords'); | |||
|
|||
// TODO: initial load should not cause change events at all, only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation?
let token = heimdall.start('AdapterPopulatedRecordArray.loadRecords'); | ||
_setInternalModels(internalModels, payload) { | ||
let token = heimdall.start('AdapterPopulatedRecordArray._setInternalModels'); | ||
let operations = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be a null object?
1af7268
to
dacfb9d
Compare
* make adding/removing from recordArrays private * make recordArray add/remove support batches * rename addInternalModel -> _pushInternalModels to be more accurate (push not add, and plural)) * [PERF] don’t use addObject in recordArrays, as the RecordArrayManager via internalRecord._recordArrays already checks containment, no need in duplicating that work by re-scanning addObject for each record added to the recordArray. * add tests, covering the duplication behavior * add comments, to ensure we don’t accidentally go back to pushObject
* cleanup code * move non-unit tests to integration folder
…uring loadRecords Replace the values contained within content, rather then replacing content. Without this we: * signal `content` changed (no point) * signal strange array mutations on the ArrayProxy (from empty content, instead of previous content); Backfill missing tests
* make the very private method more private \w underscore * rename loadRecords to _setInternalModels
dacfb9d
to
b699683
Compare
updated re: @igorT feedback |
Related to improving duplicate work:
internalModel._recordArrays
ensure we remove adapterPopulatedRecordArrays when removing an internalModel from themloadRecords
to a more private and correctly named_setInternalModels