Class Store
publicA Store coordinates interaction between your application, a Cache, and sources of data (such as your API or a local persistence layer) accessed via a RequestManager.
app/services/store.js | |
1 2 3 |
import Store from ' -data/store'; export default class extends Store {} |
Most Ember applications will only have a single Store
configured as a Service
in this manner. However, setting up multiple stores is possible, including using
each as a unique service.
cache public
Defined in ../packages/store/src/-private/store-service.ts:2398
Returns the cache instance associated to this Store, instantiates the Cache
if necessary via Store.createCache
identifierCache public
Defined in ../packages/store/src/-private/store-service.ts:139
Provides access to the IdentifierCache instance for this store.
The IdentifierCache can be used to generate or retrieve a stable unique identifier for any resource.
lifetimes public
Defined in ../packages/store/src/-private/store-service.ts:179
A Property which an App may set to provide a Lifetimes Service to control when a cached request becomes stale.
Note, when defined, these methods will only be invoked if a
cache key exists for the request, either because the request
contains cacheOptions.key
or because the IdentifierCache
was able to generate a key for the request using the configured
generation method.
isSoftExpired
will only be invoked if isHardExpired
returns false
.
1 2 3 4 5 6 7 8 9 10 11 |
store.lifetimes = { // make the request and ignore the current cache state isHardExpired(identifier: StableDocumentIdentifier): boolean { return false; } // make the request in the background if true, return cache state isSoftExpired(identifier: StableDocumentIdentifier): boolean { return false; } } |
notifications public
Defined in ../packages/store/src/-private/store-service.ts:112
Provides access to the NotificationManager associated with this Store instance.
The NotificationManager can be used to subscribe to changes to the cache.
requestManager public
Defined in ../packages/store/src/-private/store-service.ts:150
Provides access to the requestManager instance associated with this Store instance.
When using ember-data
this property is automatically
set to an instance of RequestManager
. When not using ember-data
you must configure this property yourself, either by declaring
it as a service or by initializing it.
1 2 3 4 5 6 7 8 9 10 11 12 |
import Store, { CacheHandler } from ' -data/store'; import RequestManager from ' -data/request'; import Fetch from ' /data/request/fetch'; class extends Store { constructor() { super(...arguments); this.requestManager = new RequestManager(); this.requestManager.use([Fetch]); this.requestManager.useCache(CacheHandler); } } |
schema public
Defined in ../packages/store/src/-private/store-service.ts:124
Provides access to the SchemaService instance for this Store instance.
The SchemaService can be used to query for information about the schema of a resource.