Issue with chrome.runtime.onConnect when building chrome extension in dart

帅比萌擦擦* 提交于 2019-12-05 23:24:50

After looking at common.dart in chrome.dart package:

void _ensureHandlerAdded() {
  if (!_handlerAdded) {
    // TODO: Workaround an issue where the event objects are not properly
    // proxied in M35 and after.
    var jsEvent = _api[_eventName];
    JsObject event = (jsEvent is JsObject ? jsEvent : new JsObject.fromBrowserObject(jsEvent));
    event.callMethod('addListener', [_listener]);
    _handlerAdded = true;
  }
}

it seems necessary to wrap Event into JsObject to make it working in dart:js.

The same was required for the following too:

  • port.onDisconnect
  • port.onMessage

If someone knows of an existing issue tracking this problem, please feel free to add it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!