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

Method requestOnce

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

* Make a one time event listening request. * Will unlisten after response is received. * * @param {string} requestType The type of the request message. * @param {string} responseType The type of the response message. * @param {function(Object)} callback The callback function to call

(requestType, responseType, callback)

Source from the content-addressed store, hash-verified

87 * @return {*} TODO(#23582): Specify return type
88 */
89 requestOnce(requestType, responseType, callback) {
90 const unlisten = this.registerCallback(responseType, (event) => {
91 unlisten();
92 callback(event);
93 });
94 this.sendMessage(requestType);
95 return unlisten;
96 }
97
98 /**
99 * Register callback function for message with type messageType.

Calls 4

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

Tested by

no test coverage detected