-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
API: Replace all withAPIData usage and deprecate the HoC #8584
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ export const defaultEntities = [ | |
|
||
export const kinds = [ | ||
{ name: 'postType', loadEntities: loadPostTypeEntities }, | ||
{ name: 'taxonomy', loadEntities: loadTaxonomyEntities }, | ||
]; | ||
|
||
/** | ||
|
@@ -40,6 +41,22 @@ async function loadPostTypeEntities() { | |
} ); | ||
} | ||
|
||
/** | ||
* Returns the list of the taxonomies entities. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: The function returns a promise. The promise resolves to a list of the taxonomies entities. Aside: This is probably one of the only things I dislike about |
||
* | ||
* @return {Promise} Entities promise | ||
*/ | ||
async function loadTaxonomyEntities() { | ||
const taxonomies = await apiFetch( { path: '/wp/v2/taxonomies?context=edit' } ); | ||
return map( taxonomies, ( taxonomy, name ) => { | ||
return { | ||
kind: 'taxonomy', | ||
baseURL: '/wp/v2/' + taxonomy.rest_base, | ||
name, | ||
}; | ||
} ); | ||
} | ||
|
||
/** | ||
* Returns the entity's getter method name given its kind and name. | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are going to fetch more data, is that expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, with a central store like we do right now, we can't fetch a small part of objects, we fetch the whole objects or we don't. Because the redux state always expects the full object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could, but it is super complex :)