MCPcopy
hub / github.com/ampproject/amphtml / getData

Method getData

3p/iframe-messaging-client.js:49–62  ·  view source on GitHub ↗

* Retrieves data from host. * * @param {string} requestType * @param {?Object} payload * @param {function(*)} callback

(requestType, payload, callback)

Source from the content-addressed store, hash-verified

47 * @param {function(*)} callback
48 */
49 getData(requestType, payload, callback) {
50 const responseType = requestType + CONSTANTS.responseTypeSuffix;
51 const messageId = this.nextMessageId_++;
52 const unlisten = this.registerCallback(responseType, (result) => {
53 if (result[CONSTANTS.messageIdFieldName] === messageId) {
54 unlisten();
55 callback(result[CONSTANTS.contentFieldName]);
56 }
57 });
58 const data = {};
59 data[CONSTANTS.payloadFieldName] = payload;
60 data[CONSTANTS.messageIdFieldName] = messageId;
61 this.sendMessage(requestType, data);
62 }
63
64 /**
65 * Make an event listening request.

Callers 6

getHtmlMethod · 0.80
getConsentStateMethod · 0.80
registerEventFunction · 0.80
maskScopeFunction · 0.80
hFunction · 0.80

Calls 4

registerCallbackMethod · 0.95
sendMessageMethod · 0.95
unlistenFunction · 0.85
callbackFunction · 0.50

Tested by

no test coverage detected