Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update API docs for BelongsToReference #4639

Merged
merged 1 commit into from
Nov 18, 2016

Conversation

bmac
Copy link
Member

@bmac bmac commented Nov 10, 2016

@@ -5,6 +5,16 @@ import Reference from './reference';
import isEnabled from 'ember-data/-private/features';
import { assertPolymorphicType, deprecate } from "ember-data/-private/debug";


/**
An BelongsToReference is a low level API that allows users and
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"A BelongsToReference"

/**
The link Ember Data will use to fetch or reload this belongs-to
relationship. Together, the `type()` and `id()` methods form a
composite key for the identity map.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this second sentence.


@method push
@param {Object|Promise} objectOrPromise a promise that resolves to a JSONAPI document object describing the new value of this relationship.
@return {Object} The meta information for the belongs-oo relationship.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should say push returns the record.

`value()` on a reference does not trigger a fetch if the async
relationship is not yet loaded. If the relationship is not loaded
it will always return `null`. If the relationship is already loaded
this method does not trigger a new load.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is copy and pasted from the value docs above.

Copy link
Member

@pangratz pangratz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️ Thanks so much for this!! ❤️

@@ -63,6 +253,50 @@ BelongsToReference.prototype.push = function(objectOrPromise) {
});
};

/**
`value()` sycronously returns the current value of the belongs-to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: s/sycronously/synchronously/

user: DS.belongsTo({ async: true })
});

var blog = store.push({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a valid format for store.push

user: DS.belongsTo({ async: true })
});

var blog = store.push({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a valid format for store.push

user: DS.belongsTo({ async: true })
});

var blog = store.push({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a valid format for store.push

var userRef = blog.belongsTo('user');

// provide data for reference
userRef.push({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to be a JSON-API doc of the form { data: { ... } }

user: DS.belongsTo({ async: true })
});

var blog = store.push({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a valid format for store.push

userRef.value(); // null

// provide data for reference
userRef.push({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to be a JSON-API doc of the form { data: { ... } }

user: DS.belongsTo({ async: true })
});

var blog = store.push({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a valid format for store.push

user: DS.belongsTo({ async: true })
});

var blog = store.push({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a valid format for store.push

/**
The `id` of the record that this reference refers to. Together, the
`type()` and `id()` methods form a composite key for the identity
map. This can be used to access the id of an asycn relationship
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: s/asycn/async/

@bmac
Copy link
Member Author

bmac commented Nov 18, 2016

@pangratz I've updated this pr to address your comments.

related: {
href: '/articles/1/author',
meta: {
count: 10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny nitpick: not sure if this is the best meta value for a single resource 🤔 . But then of course I don't have a better suggestion 😔 single record meta data is hard 😄

Maybe lastUpdated?

@pangratz pangratz merged commit d291f94 into emberjs:master Nov 18, 2016
@pangratz
Copy link
Member

Thanks again @bmac!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants