Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Sep 5, 2018. It is now read-only.
/client-jsPublic archive

Cache retrieved model from getter in embedded#158

Open
westonruter wants to merge3 commits intoWP-API:master
base:master
Choose a base branch
Loading
fromxwp:feature/cache-model-getter-in-embeddeds

Conversation

@westonruter
Copy link
Member

Builds on#157. The one new commit is07fea24.
Needs unit tests.

if(!getModel.get(embedCheckField)){
getModel.fetch({
success:function(model){
varupdatedEmbeddeds=_.clone(parentModel.get('_embedded')||{});

Choose a reason for hiding this comment

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

@westonruter can you explain why you are caching the parent embed here? does this prevent duplicate lookup calls? can you explain how to reproduce and i can work on a unit test to demonstrate what this fixes? thanks

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Yes, exactly. If we cache the fetchedembedded model inside of the parent's_embedded then subsequent calls will avoid doing external calls, and will instead return what was previously fetched.

The scenario where I encountered this problem was when I introduced arelated post REST field with agetRelatedPost model getter, and I wanted togetFeaturedMedia of that related post:https://github.com/xwp/wp-customize-featured-content-demo/blob/6243ce237ab2974d5d17b1d4a8895169bff3e67b/js/frontend.js#L8-L51

Choose a reason for hiding this comment

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

Great, thanks, that should help figure out a unit test. I started working on a core merge changeset, I need to fix a few docs fixes that went into core I don't want to overwrite.https://github.com/adamsilverstein/develop.wordpress/tree/pr157. I verified the existing client unit tests all pass and we'll get a run on that branch in travis now as well - the travis:js run includes the wp-api client tests -https://travis-ci.org/adamsilverstein/develop.wordpress

Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

1 more reviewer

@adamsilversteinadamsilversteinadamsilverstein left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@westonruter@adamsilverstein

[8]ページ先頭

©2009-2025 Movatter.jp