-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathstore.ts
33 lines (27 loc) · 1.23 KB
/
store.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import JSONAPICache from '@ember-data/json-api';
import type Model from '@ember-data/model';
import { instantiateRecord, teardownRecord } from '@ember-data/model';
import { buildSchema, modelFor } from '@ember-data/model/hooks';
import RequestManager from '@ember-data/request';
import Fetch from '@ember-data/request/fetch';
import DataStore, { CacheHandler } from '@ember-data/store';
import type { CacheCapabilitiesManager, ModelSchema } from '@ember-data/store/types';
import type { StableRecordIdentifier } from '@warp-drive/core-types';
export default class Store extends DataStore {
requestManager = new RequestManager().use([Fetch]).useCache(CacheHandler);
createSchemaService(): ReturnType<typeof buildSchema> {
return buildSchema(this);
}
createCache(capabilities: CacheCapabilitiesManager) {
return new JSONAPICache(capabilities);
}
instantiateRecord(identifier: StableRecordIdentifier, createRecordArgs: { [key: string]: unknown }) {
return instantiateRecord.call(this, identifier, createRecordArgs);
}
teardownRecord(record: Model) {
return teardownRecord.call(this, record);
}
modelFor(type: string): ModelSchema {
return (modelFor.call(this, type) as ModelSchema) || super.modelFor(type);
}
}