Class RecordDataManager
publicThe RecordDataManager wraps a RecordData cache enforcing that only the public API surface area is exposed.
This class is the the return value of both the
recordDataFor
function supplied to the store
hook instantiateRecord
, and the recordDataFor
method on the RecordDataStoreWrapper
. It is not
directly instantiatable.
It handles translating between cache versions when necessary, for instance when a Store is configured to use both a v1 and a v2 cache depending on some heuristic.
Starting with the v2 spec, the cache is designed such that it may be implemented as a singleton. However, because the v1 spec was not designed for this whenever we encounter any v1 cache we must wrap all caches, even singletons, in non-singleton managers to preserve v1 compatibility.
To avoid this performance penalty being paid by all applications, singleton behavior may be opted-in via the configuration supplied to your Ember application at build time. This effectively removes support for v1 caches.
1 2 3 4 5 |
let app = new EmberApp(defaults, { emberData: { useSingletonManager: true }, }); |
clientDidCreate (identifier, options) public
Defined in ../packages/store/addon/-private/managers/record-data-manager.ts:203
- identifier
- options
[LIFECYLCE] Signal to the cache that a new record has been instantiated on the client
It returns properties from options that should be set on the record during the create process. This return value behavior is deprecated.
commitWasRejected (identifier, errors) public
Defined in ../packages/store/addon/-private/managers/record-data-manager.ts:282
- identifier
- errors
[LIFECYCLE] Signals to the cache that a resource was update via a save transaction failed.
didCommit (identifier, data) public
Defined in ../packages/store/addon/-private/managers/record-data-manager.ts:263
- identifier
- data
[LIFECYCLE] Signals to the cache that a resource was successfully updated as part of a save transaction.
getAttr (identifier, propertyName) Unknown public
Defined in ../packages/store/addon/-private/managers/record-data-manager.ts:315
- identifier
- propertyName
- returns
- Unknown
Retrieve the data for an attribute from the cache
getErrors (identifier) public
Defined in ../packages/store/addon/-private/managers/record-data-manager.ts:670
- identifier
- returns
Query the cache for any validation errors applicable to the given resource.
getRelationship (identifier, propertyName) public
Defined in ../packages/store/addon/-private/managers/record-data-manager.ts:478
- identifier
- propertyName
- returns
- resource relationship object
Query the cache for the current state of a relationship property
hasChangedAttrs (identifier) Boolean public
Defined in ../packages/store/addon/-private/managers/record-data-manager.ts:426
- identifier
- returns
- Boolean
Query the cache for whether any mutated attributes exist
isDeleted (identifier) Boolean public
Defined in ../packages/store/addon/-private/managers/record-data-manager.ts:710
- identifier
- returns
- Boolean
Query the cache for whether a given resource is marked as deleted (but not necessarily persisted yet).
isDeletionCommitted (identifier) Boolean public
Defined in ../packages/store/addon/-private/managers/record-data-manager.ts:723
- identifier
- returns
- Boolean
Query the cache for whether a given resource has been deleted and that deletion has also been persisted.
isEmpty (identifier) Boolean public
Defined in ../packages/store/addon/-private/managers/record-data-manager.ts:682
- identifier
- returns
- Boolean
Query the cache for whether a given resource has any available data
isNew (identifier) Boolean public
Defined in ../packages/store/addon/-private/managers/record-data-manager.ts:697
- identifier
- returns
- Boolean
Query the cache for whether a given resource was created locally and not yet persisted.
pushData (identifier, data, hasRecord) Void | string[] public
Defined in ../packages/store/addon/-private/managers/record-data-manager.ts:107
- identifier
- data
- hasRecord
- returns
- Void | string[]
- if `hasRecord` is true then calculated key changes should be returned
Push resource data from a remote source into the cache for this identifier
rollbackAttrs (identifier) public
Defined in ../packages/store/addon/-private/managers/record-data-manager.ts:456
- identifier
- returns
- the names of attributes that were restored
Tell the cache to discard any uncommitted mutations to attributes
setAttr (identifier, propertyName, value) public
Defined in ../packages/store/addon/-private/managers/record-data-manager.ts:336
- identifier
- propertyName
- value
Mutate the data for an attribute in the cache
setIsDeleted (identifier, isDeleted) public
Defined in ../packages/store/addon/-private/managers/record-data-manager.ts:650
- identifier
- isDeleted
Update the cache state for the given resource to be marked as locally deleted, or remove such a mark.
sync (op) Void public
Defined in ../packages/store/addon/-private/managers/record-data-manager.ts:131
- op
- the operation to perform
- returns
- Void
Perform an operation on the cache to update the remote state.
Note: currently the only valid operation is a MergeOperation which occurs when a collision of identifiers is detected.
unloadRecord (identifier) public
Defined in ../packages/store/addon/-private/managers/record-data-manager.ts:295
- identifier
[LIFECYCLE] Signals to the cache that all data for a resource should be cleared.
update (operation) public
Defined in ../packages/store/addon/-private/managers/record-data-manager.ts:150
- operation
Update resource data with a local mutation. Currently supports operations on relationships only.
willCommit (identifier) public
Defined in ../packages/store/addon/-private/managers/record-data-manager.ts:251
- identifier
[LIFECYCLE] Signals to the cache that a resource will be part of a save transaction.