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

fix: replace ember assign with Object.assign #617

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions addon/utils/collection-action.ts
@@ -1,4 +1,3 @@
import { assign } from '@ember/polyfills';
import Model from 'ember-data/model';
import { Value as JSONValue } from 'json-typescript';
import { _getModelClass, _getModelName, _getStoreFromRecord, buildOperationUrl } from './build-url';
Expand All @@ -25,7 +24,7 @@ export default function collectionOp<IN = any, OUT = any>(options: CollectionOpe
const fullUrl = buildOperationUrl(model, options.path, urlType, false);
const data = (options.before && options.before.call(model, payload)) || payload;
return adapter
.ajax(fullUrl, requestType, assign(options.ajaxOptions || {}, { data }))
.ajax(fullUrl, requestType, Object.assign(options.ajaxOptions || {}, { data }))
.then((response: JSONValue) => {
if (options.after && !model.isDestroyed) {
return options.after.call(model, response);
Expand Down
15 changes: 8 additions & 7 deletions addon/utils/member-action.ts
@@ -1,4 +1,3 @@
import { assign } from '@ember/polyfills';
import Model from 'ember-data/model';
import { Value as JSONValue } from 'json-typescript';
import { _getModelClass, _getModelName, _getStoreFromRecord, buildOperationUrl } from './build-url';
Expand All @@ -23,12 +22,14 @@ export default function instanceOp<IN = any, OUT = any>(options: InstanceOperati
const adapter = store.adapterFor(modelName);
const fullUrl = buildOperationUrl(this, path, urlType);
const data = (before && before.call(this, payload)) || payload;
return adapter.ajax(fullUrl, requestType, assign(ajaxOptions || {}, { data })).then((response: JSONValue) => {
if (after && !this.isDestroyed) {
return after.call(this, response);
}
return adapter
.ajax(fullUrl, requestType, Object.assign(ajaxOptions || {}, { data }))
.then((response: JSONValue) => {
if (after && !this.isDestroyed) {
return after.call(this, response);
}

return response;
});
return response;
});
};
}
3 changes: 1 addition & 2 deletions tests/dummy/app/models/fruit.js
@@ -1,13 +1,12 @@
// BEGIN-SNIPPET fruit-model
import { assign } from '@ember/polyfills';
import { collectionAction, memberAction, serializeAndPush } from 'ember-api-actions';
import DS from 'ember-data';

const { attr, Model } = DS;

function mergeAttributes(attributes) {
const payload = this.serialize();
payload.data.attributes = assign(payload.data.attributes || {}, attributes);
payload.data.attributes = Object.assign(payload.data.attributes || {}, attributes);
return payload;
}
const Fruit = Model.extend({
Expand Down