Skip to content
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

chore: legacy-handler findRecord support #8476

Merged
merged 19 commits into from
Mar 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ module.exports = {
'@types/@ember/object/compat.d.ts',
'@types/@ember/debug/index.d.ts',
'packages/store/src/index.ts',
'packages/store/src/-private/utils/promise-record.ts',
'packages/store/src/-private/utils/is-non-empty-string.ts',
'packages/store/src/-private/utils/construct-resource.ts',
'ember-data-types/q/utils.ts',
Expand All @@ -226,7 +225,6 @@ module.exports = {
'packages/store/src/-private/caches/record-data-for.ts',
'packages/store/src/-private/utils/normalize-model-name.ts',
'packages/store/src/-private/legacy-model-support/shim-model-class.ts',
'packages/store/src/-private/network/fetch-manager.ts',
'packages/store/src/-private/store-service.ts',
'packages/store/src/-private/utils/coerce-id.ts',
'packages/store/src/-private/index.ts',
Expand Down
6 changes: 4 additions & 2 deletions packages/-ember-data/addon/-private/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import PromiseProxyMixin from '@ember/object/promise-proxy-mixin';
import ObjectProxy from '@ember/object/proxy';

import { LegacyNetworkHandler } from '@ember-data/legacy-compat';
import { FetchManager } from '@ember-data/legacy-compat/-private';
import { RequestManager } from '@ember-data/request';
import { Fetch } from '@ember-data/request/fetch';
import BaseStore from '@ember-data/store';

export class Store extends BaseStore {
constructor() {
super(...arguments);
constructor(args: Record<string, unknown>) {
super(args);
this._fetchManager = new FetchManager(this);
this.requestManager = new RequestManager();
this.requestManager.use([LegacyNetworkHandler, Fetch]);
}
Expand Down
3 changes: 2 additions & 1 deletion packages/-ember-data/addon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ import JSONSerializer from '@ember-data/serializer/json';
import JSONAPISerializer from '@ember-data/serializer/json-api';
import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';
import Transform from '@ember-data/serializer/transform';
import Store, { normalizeModelName } from '@ember-data/store';
import { normalizeModelName } from '@ember-data/store';

import {
DS,
Expand All @@ -197,6 +197,7 @@ import {
PromiseObject,
RecordArrayManager,
Snapshot,
Store,
} from './-private';
import setupContainer from './setup-container';

Expand Down
2 changes: 2 additions & 0 deletions packages/legacy-compat/src/-private.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export { default as SnapshotRecordArray } from './legacy-network-handler/snapshot-record-array';
export { SaveOp } from './legacy-network-handler/fetch-manager';
export { default as FetchManager } from './legacy-network-handler/fetch-manager';
10 changes: 8 additions & 2 deletions packages/legacy-compat/src/legacy-network-handler/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ import { resolve } from 'rsvp';
import { DEBUG } from '@ember-data/env';
import { DEPRECATE_RSVP_PROMISE } from '@ember-data/private-build-infra/deprecations';

function _guard(promise, test) {
export function _bind(fn, ...args) {
return function () {
return fn.apply(undefined, args);
};
}

export function _guard(promise, test) {
let guarded = promise.finally(() => {
if (!test()) {
guarded._subscribers.length = 0;
Expand All @@ -15,7 +21,7 @@ function _guard(promise, test) {
return guarded;
}

function _objectIsAlive(object) {
export function _objectIsAlive(object) {
return !(object.isDestroyed || object.isDestroying);
}

Expand Down
Loading