Skip to content

Commit

Permalink
remove decorator CP usage from es6 classes (emberjs#6331)
Browse files Browse the repository at this point in the history
  • Loading branch information
igorT authored Aug 15, 2019
1 parent 95f6694 commit 963645c
Showing 1 changed file with 32 additions and 28 deletions.
60 changes: 32 additions & 28 deletions packages/store/addon/-private/system/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { registerWaiter, unregisterWaiter } from '@ember/test';
import { A } from '@ember/array';
import EmberError from '@ember/error';
import { run as emberRunLoop } from '@ember/runloop';
import { set, get, computed } from '@ember/object';
import { set, get, computed, defineProperty } from '@ember/object';
import { getOwner } from '@ember/application';
import { assign } from '@ember/polyfills';
import { default as RSVP, all, resolve, Promise, defer } from 'rsvp';
Expand Down Expand Up @@ -236,6 +236,22 @@ class Store extends Service {
@type {String}
*/

/**
This property returns the adapter, after resolving a possible
string key.
If the supplied `adapter` was a class, or a String property
path resolved to a class, this property will instantiate the
class.
This property is cacheable, so the same instance of a specified
adapter class should be used for the lifetime of the store.
@property defaultAdapter
@private
@return Adapter
*/

/**
@method init
@private
Expand Down Expand Up @@ -308,33 +324,6 @@ class Store extends Service {
throw 'RequestService is not available unless the feature flag is on and running on a canary build';
}

/**
This property returns the adapter, after resolving a possible
string key.
If the supplied `adapter` was a class, or a String property
path resolved to a class, this property will instantiate the
class.
This property is cacheable, so the same instance of a specified
adapter class should be used for the lifetime of the store.
@property defaultAdapter
@private
@return Adapter
*/
@computed('adapter')
get defaultAdapter() {
let adapter = this.adapter || '-json-api';

assert(
'You tried to set `adapter` property to an instance of `Adapter`, where it should be a name',
typeof adapter === 'string'
);

return this.adapterFor(adapter);
}

get identifierCache(): IdentifierCache {
if (!IDENTIFIERS) {
throw new Error(`Store.identifierCache is unavailable in this build of EmberData`);
Expand Down Expand Up @@ -3238,6 +3227,21 @@ class Store extends Service {
}
}

defineProperty(
Store.prototype,
'defaultAdapter',
computed('adapter', function() {
let adapter = this.adapter || '-json-api';

assert(
'You tried to set `adapter` property to an instance of `Adapter`, where it should be a name',
typeof adapter === 'string'
);

return this.adapterFor(adapter);
})
);

export default Store;

function _commit(adapter, store, operation, snapshot) {
Expand Down

0 comments on commit 963645c

Please sign in to comment.