@ember-data/store 4.10.0-beta.2 → 4.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -423,21 +423,16 @@ export class InstanceCache {
|
|
|
423
423
|
}
|
|
424
424
|
}
|
|
425
425
|
|
|
426
|
-
let removeFromRecordArray = true;
|
|
427
426
|
if (recordData) {
|
|
428
|
-
removeFromRecordArray = !recordData.isDeletionCommitted(identifier);
|
|
429
427
|
recordData.unloadRecord(identifier);
|
|
430
428
|
this.__instances.recordData.delete(identifier);
|
|
431
429
|
removeRecordDataFor(identifier);
|
|
432
430
|
} else {
|
|
433
|
-
removeFromRecordArray = false;
|
|
434
431
|
this.disconnect(identifier);
|
|
435
432
|
}
|
|
436
433
|
|
|
437
434
|
this.store._fetchManager.clearEntries(identifier);
|
|
438
|
-
|
|
439
|
-
this.store.recordArrayManager.identifierRemoved(identifier);
|
|
440
|
-
}
|
|
435
|
+
this.store.recordArrayManager.identifierRemoved(identifier);
|
|
441
436
|
if (LOG_INSTANCE_CACHE) {
|
|
442
437
|
// eslint-disable-next-line no-console
|
|
443
438
|
console.log(`InstanceCache: unloaded RecordData for ${String(identifier)}`);
|
|
@@ -357,10 +357,7 @@ function sync(array: IdentifierArray, changes: Map<StableRecordIdentifier, 'add'
|
|
|
357
357
|
// state = array[SOURCE] = [];
|
|
358
358
|
} else {
|
|
359
359
|
removes.forEach((i) => {
|
|
360
|
-
|
|
361
|
-
if (index !== -1) {
|
|
362
|
-
state.splice(index, 1);
|
|
363
|
-
}
|
|
360
|
+
state.splice(state.indexOf(i), 1);
|
|
364
361
|
});
|
|
365
362
|
}
|
|
366
363
|
}
|
|
@@ -119,7 +119,7 @@ export class NonSingletonRecordDataManager implements RecordData {
|
|
|
119
119
|
// called by something V1
|
|
120
120
|
if (!isStableIdentifier(identifier)) {
|
|
121
121
|
data = identifier as JsonApiResource;
|
|
122
|
-
hasRecord = data as
|
|
122
|
+
hasRecord = data as boolean;
|
|
123
123
|
identifier = this.#identifier;
|
|
124
124
|
}
|
|
125
125
|
if (this.#isDeprecated(recordData)) {
|
|
@@ -114,33 +114,6 @@ interface PrivateState {
|
|
|
114
114
|
links: Links | PaginationLinks | null;
|
|
115
115
|
meta: Dict<unknown> | null;
|
|
116
116
|
}
|
|
117
|
-
type ForEachCB = (record: RecordInstance, index: number, context: IdentifierArray) => void;
|
|
118
|
-
function safeForEach(
|
|
119
|
-
instance: IdentifierArray,
|
|
120
|
-
arr: StableRecordIdentifier[],
|
|
121
|
-
store: Store,
|
|
122
|
-
callback: ForEachCB,
|
|
123
|
-
target: unknown
|
|
124
|
-
) {
|
|
125
|
-
if (target === undefined) {
|
|
126
|
-
target = null;
|
|
127
|
-
}
|
|
128
|
-
// clone to prevent mutation
|
|
129
|
-
arr = arr.slice();
|
|
130
|
-
assert('`forEach` expects a function as first argument.', typeof callback === 'function');
|
|
131
|
-
|
|
132
|
-
// because we retrieveLatest above we need not worry if array is mutated during iteration
|
|
133
|
-
// by unloadRecord/rollbackAttributes
|
|
134
|
-
// push/add/removeObject may still be problematic
|
|
135
|
-
// but this is a more traditionally expected forEach bug.
|
|
136
|
-
const length = arr.length; // we need to access length to ensure we are consumed
|
|
137
|
-
|
|
138
|
-
for (let index = 0; index < length; index++) {
|
|
139
|
-
callback.call(target, store._instanceCache.getRecord(arr[index]), index, instance);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return instance;
|
|
143
|
-
}
|
|
144
117
|
|
|
145
118
|
/**
|
|
146
119
|
A record array is an array that contains records of a certain type (or modelName).
|
|
@@ -268,25 +241,15 @@ class IdentifierArray {
|
|
|
268
241
|
let fn = boundFns.get(prop);
|
|
269
242
|
|
|
270
243
|
if (fn === undefined) {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}
|
|
280
|
-
fn = function () {
|
|
281
|
-
subscribe(_TAG);
|
|
282
|
-
// array functions must run through Reflect to work properly
|
|
283
|
-
// binding via other means will not work.
|
|
284
|
-
transaction = true;
|
|
285
|
-
let result = Reflect.apply(target[prop] as ProxiedMethod, receiver, arguments) as unknown;
|
|
286
|
-
transaction = false;
|
|
287
|
-
return result;
|
|
288
|
-
};
|
|
289
|
-
}
|
|
244
|
+
fn = function () {
|
|
245
|
+
subscribe(_TAG);
|
|
246
|
+
// array functions must run through Reflect to work properly
|
|
247
|
+
// binding via other means will not work.
|
|
248
|
+
transaction = true;
|
|
249
|
+
let result = Reflect.apply(target[prop] as ProxiedMethod, receiver, arguments) as unknown;
|
|
250
|
+
transaction = false;
|
|
251
|
+
return result;
|
|
252
|
+
};
|
|
290
253
|
|
|
291
254
|
boundFns.set(prop, fn);
|
|
292
255
|
}
|
|
@@ -308,7 +271,7 @@ class IdentifierArray {
|
|
|
308
271
|
const args: unknown[] = Array.prototype.slice.call(arguments);
|
|
309
272
|
assert(`Cannot start a new array transaction while a previous transaction is underway`, !transaction);
|
|
310
273
|
transaction = true;
|
|
311
|
-
let result
|
|
274
|
+
let result = Reflect.apply(target[prop] as ProxiedMethod, receiver, args) as unknown;
|
|
312
275
|
self[MUTATE]!(prop as string, args, result);
|
|
313
276
|
addToTransaction(_TAG);
|
|
314
277
|
// TODO handle cache updates
|
|
@@ -695,21 +658,13 @@ if (DEPRECATE_ARRAY_LIKE) {
|
|
|
695
658
|
|
|
696
659
|
IdentifierArray.prototype.removeObject = function (obj: RecordInstance) {
|
|
697
660
|
deprecateArrayLike(this.DEPRECATED_CLASS_NAME, 'removeObject', 'splice');
|
|
698
|
-
|
|
699
|
-
if (index !== -1) {
|
|
700
|
-
this.splice(index, 1);
|
|
701
|
-
}
|
|
661
|
+
this.splice(this.indexOf(obj), 1);
|
|
702
662
|
return this;
|
|
703
663
|
};
|
|
704
664
|
|
|
705
665
|
IdentifierArray.prototype.removeObjects = function (objs: RecordInstance[]) {
|
|
706
666
|
deprecateArrayLike(this.DEPRECATED_CLASS_NAME, 'removeObjects', 'splice');
|
|
707
|
-
objs.forEach((obj) =>
|
|
708
|
-
const index = this.indexOf(obj);
|
|
709
|
-
if (index !== -1) {
|
|
710
|
-
this.splice(index, 1);
|
|
711
|
-
}
|
|
712
|
-
});
|
|
667
|
+
objs.forEach((obj) => this.splice(this.indexOf(obj), 1));
|
|
713
668
|
return this;
|
|
714
669
|
};
|
|
715
670
|
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ember-data/store",
|
|
3
|
-
"version": "4.10.0
|
|
3
|
+
"version": "4.10.0",
|
|
4
4
|
"description": "The core of EmberData. Provides the Store service which coordinates the cache with the network and presentation layers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"author": "",
|
|
15
15
|
"directories": {},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"@ember-data/model": "4.10.0
|
|
18
|
-
"@ember-data/record-data": "4.10.0
|
|
19
|
-
"@ember-data/tracking": "4.10.0
|
|
20
|
-
"@ember/string": "^3.0.
|
|
17
|
+
"@ember-data/model": "4.10.0",
|
|
18
|
+
"@ember-data/record-data": "4.10.0",
|
|
19
|
+
"@ember-data/tracking": "4.10.0",
|
|
20
|
+
"@ember/string": "^3.0.1",
|
|
21
21
|
"@glimmer/tracking": "^1.1.2"
|
|
22
22
|
},
|
|
23
23
|
"peerDependenciesMeta": {
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@ember-data/canary-features": "4.10.0
|
|
41
|
-
"@ember-data/private-build-infra": "4.10.0
|
|
40
|
+
"@ember-data/canary-features": "4.10.0",
|
|
41
|
+
"@ember-data/private-build-infra": "4.10.0",
|
|
42
42
|
"@embroider/macros": "^1.10.0",
|
|
43
|
-
"ember-auto-import": "^2.
|
|
43
|
+
"ember-auto-import": "^2.4.3",
|
|
44
44
|
"ember-cached-decorator-polyfill": "^1.0.1",
|
|
45
45
|
"ember-cli-babel": "^7.26.11"
|
|
46
46
|
},
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"volta": {
|
|
58
58
|
"extends": "../../package.json"
|
|
59
59
|
},
|
|
60
|
-
"packageManager": "pnpm@7.
|
|
60
|
+
"packageManager": "pnpm@7.15.0"
|
|
61
61
|
}
|