1 | import JSONAPICache from '@ember-data/json-api';
|
2 | import { LegacyNetworkHandler, adapterFor, serializerFor, pushPayload, normalize, serializeRecord, cleanup } from '@ember-data/legacy-compat';
|
3 | import { buildSchema, instantiateRecord, teardownRecord, modelFor } from '@ember-data/model/hooks';
|
4 | import RequestManager from '@ember-data/request';
|
5 | import Fetch from '@ember-data/request/fetch';
|
6 | import BaseStore, { CacheHandler } from '@ember-data/store';
|
7 | function hasRequestManager(store) {
|
8 | return 'requestManager' in store;
|
9 | }
|
10 | class Store extends BaseStore {
|
11 | constructor(args) {
|
12 | super(args);
|
13 | if (!hasRequestManager(this)) {
|
14 | this.requestManager = new RequestManager();
|
15 | this.requestManager.use([LegacyNetworkHandler, Fetch]);
|
16 | }
|
17 | this.requestManager.useCache(CacheHandler);
|
18 | }
|
19 | createSchemaService() {
|
20 | return buildSchema(this);
|
21 | }
|
22 | createCache(storeWrapper) {
|
23 | return new JSONAPICache(storeWrapper);
|
24 | }
|
25 | instantiateRecord(identifier, createRecordArgs) {
|
26 | return instantiateRecord.call(this, identifier, createRecordArgs);
|
27 | }
|
28 | teardownRecord(record) {
|
29 | teardownRecord.call(this, record);
|
30 | }
|
31 | modelFor(type) {
|
32 | return modelFor.call(this, type) || super.modelFor(type);
|
33 | }
|
34 | adapterFor = adapterFor;
|
35 | serializerFor = serializerFor;
|
36 | pushPayload = pushPayload;
|
37 | normalize = normalize;
|
38 | serializeRecord = serializeRecord;
|
39 | destroy() {
|
40 | cleanup.call(this);
|
41 | super.destroy();
|
42 | }
|
43 | }
|
44 | export { Store as default }; |
\ | No newline at end of file |