@ember-data/model 5.1.0-alpha.7 → 5.1.0-alpha.9
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.
package/addon/-private.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as Model } from "./has-many-
|
|
2
|
-
export { E as Errors, L as LEGACY_SUPPORT, R as ManyArray, P as PromiseBelongsTo, c as PromiseManyArray, a as attr, b as belongsTo, h as hasMany } from "./has-many-
|
|
1
|
+
import { M as Model } from "./has-many-1937fb05";
|
|
2
|
+
export { E as Errors, L as LEGACY_SUPPORT, R as ManyArray, P as PromiseBelongsTo, c as PromiseManyArray, a as attr, b as belongsTo, h as hasMany } from "./has-many-1937fb05";
|
|
3
3
|
import { getOwner } from '@ember/application';
|
|
4
4
|
|
|
5
5
|
/*
|
|
@@ -2204,6 +2204,7 @@ class LegacySupport {
|
|
|
2204
2204
|
this._manyArrayCache = Object.create(null);
|
|
2205
2205
|
this._relationshipPromisesCache = Object.create(null);
|
|
2206
2206
|
this._relationshipProxyCache = Object.create(null);
|
|
2207
|
+
this._pending = Object.create(null);
|
|
2207
2208
|
this.references = Object.create(null);
|
|
2208
2209
|
}
|
|
2209
2210
|
_syncArray(array) {
|
|
@@ -2550,12 +2551,13 @@ class LegacySupport {
|
|
|
2550
2551
|
if (!resource) {
|
|
2551
2552
|
return Promise.resolve(null);
|
|
2552
2553
|
}
|
|
2554
|
+
const key = relationship.definition.key;
|
|
2553
2555
|
|
|
2554
2556
|
// interleaved promises mean that we MUST cache this here
|
|
2555
2557
|
// in order to prevent infinite re-render if the request
|
|
2556
2558
|
// fails.
|
|
2557
|
-
if (this._pending) {
|
|
2558
|
-
return this._pending;
|
|
2559
|
+
if (this._pending[key]) {
|
|
2560
|
+
return this._pending[key];
|
|
2559
2561
|
}
|
|
2560
2562
|
const identifier = resource.data ? resource.data : null;
|
|
2561
2563
|
assert(`Expected a stable identifier`, !identifier || isStableIdentifier(identifier));
|
|
@@ -2589,10 +2591,10 @@ class LegacySupport {
|
|
|
2589
2591
|
[Symbol.for('ember-data:skip-cache')]: true
|
|
2590
2592
|
}
|
|
2591
2593
|
});
|
|
2592
|
-
this._pending = future.then(doc => doc.content).finally(() => {
|
|
2593
|
-
this._pending =
|
|
2594
|
+
this._pending[key] = future.then(doc => doc.content).finally(() => {
|
|
2595
|
+
this._pending[key] = undefined;
|
|
2594
2596
|
});
|
|
2595
|
-
return this._pending;
|
|
2597
|
+
return this._pending[key];
|
|
2596
2598
|
}
|
|
2597
2599
|
const preferLocalCache = hasReceivedData && allInverseRecordsAreLoaded && !isEmpty;
|
|
2598
2600
|
const hasLocalPartialData = hasDematerializedInverse || isEmpty && resource.data;
|
|
@@ -2615,7 +2617,7 @@ class LegacySupport {
|
|
|
2615
2617
|
if (identifier) {
|
|
2616
2618
|
assert(`Cannot fetch belongs-to relationship with no information`, identifier);
|
|
2617
2619
|
options.reload = options.reload || !attemptLocalCache || undefined;
|
|
2618
|
-
this._pending = this.store.request({
|
|
2620
|
+
this._pending[key] = this.store.request({
|
|
2619
2621
|
op: 'findBelongsTo',
|
|
2620
2622
|
records: [identifier],
|
|
2621
2623
|
data: request,
|
|
@@ -2623,9 +2625,9 @@ class LegacySupport {
|
|
|
2623
2625
|
[Symbol.for('ember-data:skip-cache')]: true
|
|
2624
2626
|
}
|
|
2625
2627
|
}).then(doc => doc.content).finally(() => {
|
|
2626
|
-
this._pending =
|
|
2628
|
+
this._pending[key] = undefined;
|
|
2627
2629
|
});
|
|
2628
|
-
return this._pending;
|
|
2630
|
+
return this._pending[key];
|
|
2629
2631
|
}
|
|
2630
2632
|
|
|
2631
2633
|
// we were explicitly told we have no data and no links.
|