MCPcopy Index your code
hub / github.com/ampproject/amphtml / addService

Method addService

src/service/extensions-impl.js:402–418  ·  view source on GitHub ↗

* Add a service to the extension currently being registered. This is a * restricted method and it's allowed to be called only during the overall * extension registration. * @param {string} name * @param {function(new:Object, !./ampdoc-impl.AmpDoc)} implementationClass

(name, implementationClass)

Source from the content-addressed store, hash-verified

400 * @param {function(new:Object, !./ampdoc-impl.AmpDoc)} implementationClass
401 */
402 addService(name, implementationClass) {
403 const holder = this.getCurrentExtensionHolder_(name);
404 holder.extension.services.push(
405 /** @type {!ExtensionServiceDef} */ ({
406 serviceName: name,
407 serviceClass: implementationClass,
408 })
409 );
410 this.addDocFactory((ampdoc) => {
411 registerServiceBuilderForDoc(
412 ampdoc,
413 name,
414 implementationClass,
415 /* instantiate */ true
416 );
417 });
418 }
419
420 /**
421 * Add a ampdoc factory to the extension currently being registered. This is a

Callers 1

test-extensions.jsFile · 0.80

Calls 4

addDocFactoryMethod · 0.95
pushMethod · 0.45

Tested by

no test coverage detected