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

Framework: Preload common API data #2501

Merged
merged 2 commits into from
Aug 29, 2017
Merged

Framework: Preload common API data #2501

merged 2 commits into from
Aug 29, 2017

Conversation

aduth
Copy link
Member

@aduth aduth commented Aug 22, 2017

Related: #1974

This pull request seeks to introduce a mechanism for bootstrapping common REST API requirements for use in with the withAPIData higher-order component (#1974). Specifically, this improves perceived performance by making endpoint data available immediately upon page load, avoiding components flashing in and out (e.g. LastRevision in ##1974, PostFormats in #2500) where the API data would otherwise load asynchronously.

Implementation notes:

While not entirely necessary for the changes here, I split the response between body and headers. This will be useful for future enhancements to the withAPIData higher-order component in allowing a "has more results?" type functionality.

Testing instructions:

Repeat testing instructions from #1974, noting that the LastRevision component appears immediately upon page load if revisions are available for a post. Ensure that there is no network request occurring to retrieve /wp/v2/posts/%d/revisions.

@aduth aduth added the [Feature] UI Components Impacts or related to the UI component system label Aug 22, 2017
@codecov
Copy link

codecov bot commented Aug 22, 2017

Codecov Report

Merging #2501 into master will increase coverage by 0.03%.
The diff coverage is 88.88%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2501      +/-   ##
==========================================
+ Coverage   31.57%   31.61%   +0.03%     
==========================================
  Files         175      175              
  Lines        5304     5308       +4     
  Branches      914      914              
==========================================
+ Hits         1675     1678       +3     
- Misses       3081     3082       +1     
  Partials      548      548
Impacted Files Coverage Δ
components/higher-order/with-api-data/index.js 82.66% <100%> (ø) ⬆️
components/higher-order/with-api-data/request.js 96% <87.5%> (-4%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 09380a4...86b7f93. Read the comment docs.

Auto-draft post will include link relation for version history, but would never have revisions
@aduth aduth merged commit 5b5048f into master Aug 29, 2017
@aduth aduth deleted the add/api-data-preload branch August 29, 2017 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] UI Components Impacts or related to the UI component system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant