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

Remove several getServiceForDoc() in extensions/* #22511

Merged
merged 14 commits into from
Jun 11, 2019

Conversation

dreamofabear
Copy link

@dreamofabear dreamofabear commented May 25, 2019

Partial for #22414. Removes synchronous service getter getServiceForDoc usage in extensions code.

LiveListManager.forDoc(this.element).then(manager => {
this.manager_ = manager;
this.manager_.register(this.liveListId_, this);
});
Copy link
Author

Choose a reason for hiding this comment

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

@erwinmombay PTAL at amp-live-list code.

Copy link
Author

Choose a reason for hiding this comment

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

As discussed, changes are needed to make sure that this delayed register calls triggers polling.

Copy link
Author

Choose a reason for hiding this comment

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

This is fixed in 2491276.

Copy link
Member

Choose a reason for hiding this comment

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

LGTM

'height': '1px',
'overflow': 'hidden',
'visibility': 'hidden',
});
Copy link
Author

Choose a reason for hiding this comment

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

@torch2424 PTAL at amp-recaptcha-input code.

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM @choumx Thank you for this! 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, just to be double-sure, I tested it, and it also works in manual testing:

Screen Shot 2019-05-30 at 12 31 02 PM

element,
'position-observer'
));
}
Copy link
Author

Choose a reason for hiding this comment

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

@zhouyx PTAL at PositionObserver usages above.

Copy link
Contributor

Choose a reason for hiding this comment

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

sorry, missed the comment here. LGTM

/**
* Returns a service to register callbacks we wish to execute when an
* amp-form is submitted.
* @param {!Element|!./service/ampdoc-impl.AmpDoc} elementOrAmpDoc
* @return {!Promise<../extensions/amp-form/0.1/form-submit-service.FormSubmitService>}
*/
static formSubmitPromiseForDoc(elementOrAmpDoc) {
static formSubmitForDoc(elementOrAmpDoc) {
Copy link
Author

Choose a reason for hiding this comment

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

@cvializ PTAL at FormSubmitService usage above.

Copy link
Contributor

Choose a reason for hiding this comment

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

It should be OK as it is above, since the amp-form extension registers the service. But to make it safe from future changes or races I think it would be better the save a reference to the Promise and then it when a service reference is needed, like how the amp-analytics linker-manager.js does it.


webPushServiceForDoc(this.element).then(service => {
service.start(config).catch(() => {});
});
Copy link
Author

Choose a reason for hiding this comment

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

@jasonpang PTAL at amp-web-push code.

Copy link
Contributor

@jasonpang jasonpang left a comment

Choose a reason for hiding this comment

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

LGTM

/**
* Returns a service to register callbacks we wish to execute when an
* amp-form is submitted.
* @param {!Element|!./service/ampdoc-impl.AmpDoc} elementOrAmpDoc
* @return {!Promise<../extensions/amp-form/0.1/form-submit-service.FormSubmitService>}
*/
static formSubmitPromiseForDoc(elementOrAmpDoc) {
static formSubmitForDoc(elementOrAmpDoc) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It should be OK as it is above, since the amp-form extension registers the service. But to make it safe from future changes or races I think it would be better the save a reference to the Promise and then it when a service reference is needed, like how the amp-analytics linker-manager.js does it.

@dreamofabear dreamofabear merged commit 3e0c105 into ampproject:master Jun 11, 2019
@dreamofabear dreamofabear deleted the fix-several-sync-service branch June 11, 2019 18:28
thekorn pushed a commit to edelight/amphtml that referenced this pull request Sep 11, 2019
* Fix fx-collection, next-page, position-observer, video-docking and web-push.

* Fix test-live-list-manager.js.

* Fix test-amp-user-notification.

* Fix amp-recaptcha-service.

* Remove sync formSubmitForDoc.

* Fix types.

* Fix types.

* Fix test-amp-live-list.js.

* Fix test-amp-recaptcha-input.js.

* Add issue # to presubmit message.

* Start live list polling on register(), if not already started.

* Check this.poller_ instead of doc ready.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants