|
5 | 5 | import { getOwner } from '@ember/application';
|
6 | 6 | import { assert } from '@ember/debug';
|
7 | 7 | import EmberObject from '@ember/object';
|
8 |
| -import { _backburner as emberBackburner } from '@ember/runloop'; |
9 | 8 |
|
10 | 9 | import type { Object as JSONObject } from 'json-typescript';
|
11 | 10 |
|
@@ -664,47 +663,45 @@ class Store extends EmberObject {
|
664 | 663 | //
|
665 | 664 | // to remove this, we would need to move to a new `async` API.
|
666 | 665 | let record!: RecordInstance;
|
667 |
| - emberBackburner.join(() => { |
668 |
| - this._join(() => { |
669 |
| - let normalizedModelName = normalizeModelName(modelName); |
670 |
| - let properties = { ...inputProperties }; |
| 666 | + this._join(() => { |
| 667 | + let normalizedModelName = normalizeModelName(modelName); |
| 668 | + let properties = { ...inputProperties }; |
671 | 669 |
|
672 |
| - // If the passed properties do not include a primary key, |
673 |
| - // give the adapter an opportunity to generate one. Typically, |
674 |
| - // client-side ID generators will use something like uuid.js |
675 |
| - // to avoid conflicts. |
| 670 | + // If the passed properties do not include a primary key, |
| 671 | + // give the adapter an opportunity to generate one. Typically, |
| 672 | + // client-side ID generators will use something like uuid.js |
| 673 | + // to avoid conflicts. |
676 | 674 |
|
677 |
| - if (properties.id === null || properties.id === undefined) { |
678 |
| - let adapter = this.adapterFor(modelName, true); |
| 675 | + if (properties.id === null || properties.id === undefined) { |
| 676 | + let adapter = this.adapterFor(modelName, true); |
679 | 677 |
|
680 |
| - if (adapter && adapter.generateIdForRecord) { |
681 |
| - properties.id = adapter.generateIdForRecord(this, modelName, properties); |
682 |
| - } else { |
683 |
| - properties.id = null; |
684 |
| - } |
| 678 | + if (adapter && adapter.generateIdForRecord) { |
| 679 | + properties.id = adapter.generateIdForRecord(this, modelName, properties); |
| 680 | + } else { |
| 681 | + properties.id = null; |
685 | 682 | }
|
| 683 | + } |
686 | 684 |
|
687 |
| - // Coerce ID to a string |
688 |
| - properties.id = coerceId(properties.id); |
689 |
| - const resource = { type: normalizedModelName, id: properties.id }; |
| 685 | + // Coerce ID to a string |
| 686 | + properties.id = coerceId(properties.id); |
| 687 | + const resource = { type: normalizedModelName, id: properties.id }; |
690 | 688 |
|
691 |
| - if (resource.id) { |
692 |
| - const identifier = this.identifierCache.peekRecordIdentifier(resource as ResourceIdentifierObject); |
| 689 | + if (resource.id) { |
| 690 | + const identifier = this.identifierCache.peekRecordIdentifier(resource as ResourceIdentifierObject); |
693 | 691 |
|
694 |
| - assert( |
695 |
| - `The id ${String(properties.id)} has already been used with another '${normalizedModelName}' record.`, |
696 |
| - !identifier |
697 |
| - ); |
698 |
| - } |
| 692 | + assert( |
| 693 | + `The id ${String(properties.id)} has already been used with another '${normalizedModelName}' record.`, |
| 694 | + !identifier |
| 695 | + ); |
| 696 | + } |
699 | 697 |
|
700 |
| - const identifier = this.identifierCache.createIdentifierForNewRecord(resource); |
701 |
| - const cache = this.cache; |
| 698 | + const identifier = this.identifierCache.createIdentifierForNewRecord(resource); |
| 699 | + const cache = this.cache; |
702 | 700 |
|
703 |
| - const createOptions = normalizeProperties(this, identifier, properties); |
704 |
| - const resultProps = cache.clientDidCreate(identifier, createOptions); |
| 701 | + const createOptions = normalizeProperties(this, identifier, properties); |
| 702 | + const resultProps = cache.clientDidCreate(identifier, createOptions); |
705 | 703 |
|
706 |
| - record = this._instanceCache.getRecord(identifier, resultProps); |
707 |
| - }); |
| 704 | + record = this._instanceCache.getRecord(identifier, resultProps); |
708 | 705 | });
|
709 | 706 | return record;
|
710 | 707 | }
|
@@ -738,9 +735,7 @@ class Store extends EmberObject {
|
738 | 735 | cache.setIsDeleted(identifier, true);
|
739 | 736 |
|
740 | 737 | if (cache.isNew(identifier)) {
|
741 |
| - emberBackburner.join(() => { |
742 |
| - this._instanceCache.unloadRecord(identifier); |
743 |
| - }); |
| 738 | + this._instanceCache.unloadRecord(identifier); |
744 | 739 | }
|
745 | 740 | });
|
746 | 741 | }
|
|
0 commit comments