Skip to content

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.

@aduth aduth force-pushed the add/api-data-preload branch 2 times, most recently from da4f155 to 398f328 Compare August 28, 2017 16:25
@aduth aduth force-pushed the add/api-data-preload branch from 398f328 to e5a5252 Compare August 29, 2017 12:37
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.

2 participants