API Docs for:
Show:

RelationshipPayloadsManager Class

Manages relationship payloads for a given store, for uninitialized relationships. Acts as a single source of truth (of payloads) for both sides of an uninitialized relationship so they can agree on the most up-to-date payload received without needing too much eager processing when those payloads are pushed into the store.

This minimizes the work spent on relationships that are never initialized.

Once relationships are initialized, their state is managed in a relationship state object (eg BelongsToRelationship or ManyRelationship).

Item Index

Methods

Methods

()

Find the payload for the given relationship of the given model.

Returns the payload for the given relationship, whether raw or computed from the payload of the inverse relationship.

Example:

relationshipPayloadsManager.get('hobby', 2, 'user') === { { data: { id: 1, type: 'user' } } }

()

Push a model's relationships payload into this cache.

Example:

let userPayload = { data: { id: 1, type: 'user', relationships: { hobbies: { data: [{ id: 2, type: 'hobby' }] } } }, }; relationshipPayloadsManager.push('user', 1, userPayload.data.relationships);

()

Unload a model's relationships payload.

() private

Find the RelationshipPayloads object for the given relationship. The same RelationshipPayloads object is returned for either side of a relationship.

Example:

const User = DS.Model.extend({ hobbies: DS.hasMany('hobby') });

const Hobby = DS.Model.extend({ user: DS.belongsTo('user') });

relationshipPayloads.get('user', 'hobbies') === relationshipPayloads.get('hobby', 'user');

The signature has a somewhat large arity to avoid extra work, such as a) string manipulation & allocation with modelName and relationshipName b) repeatedly getting relationshipsByName via Ember.get

() private

Create the RelationshipsPayload for the relationship modelName, relationshipName, and its inverse.