* Retrieves data from host. * * @param {string} requestType * @param {?Object} payload * @param {function(*)} callback
(requestType, payload, callback)
| 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. |
no test coverage detected