【发布时间】:2018-08-10 02:12:20
【问题描述】:
我们如何在 dart 2 中实现这一点?
content_script.js:
chrome.runtime.sendMessage("hello", function(response) {
console.log(response);
});
背景.js:
chrome.runtime.onMessage.addListener(function(a,b, responseCallback){
responseCallback("world");
});
当从 dart 调用 responseCallback("world"); 时,它不会将响应发送回发送者。
我已经实现了一个示例,该示例能够在事件触发时从事件中读取参数,但由于responseCallback 作为参数传递,因此无法发送响应:
https://gitlab.com/drbcode/chrome.dart/blob/master/examples/runtime_test/lib/runtime.dart#L46
API 文档:
https://developer.chrome.com/apps/runtime#method-sendMessage https://developer.chrome.com/apps/runtime#event-onMessage
【问题讨论】:
标签: dart dart-js-interop