-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
browser.runtime.onMessage.addListener only accepts 2 arguments #54
Comments
created pull request here: |
Please merge this ASAP |
As you can see in the page you linked: "Returning a Promise is now preferred, as sendResponse() will be removed from the W3C spec." Please use a promise as return value instead of using sendResponse. I'm going to keep this open, as this pops up regularly, as people don't seem to search before opening new tickets: #53, #46, #45, #31, #7 |
I landed here from Chrome Developer website where I found no mention about returning a Promise, however I gave it a try and just wanted to confirm that this works the same as calling
|
Chrome documentation is not about the W3C standard. They don't care about the standard at all. If you try to target multiple browsers, I suggest you use the MDN documentation. Of course, there will be things you need to check if you want chrome-only features and for that you'll need to use the chrome documentation. |
This makes it not easy to pass Observable from backgroundScript to contentScript, an Observable need to send multiple times, after subscribe. I need something like const ovserver = {
next: (value) => sender.send(subscriptionId, { type: ResponseType.Next, value }),
error: (error: Error) => sender.send(subscriptionId, { type: ResponseType.Error, error: Errio.stringify(error) }),
complete: () => sender.send(subscriptionId, { type: ResponseType.Complete }),
}; To achieve something like https://github.com/frankwallis/electron-ipc-proxy |
@linonetwo That's not how If you call
|
As seen in mozilla/webextension-polyfill#386 (comment) See also updated MDN documentation: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onMessage |
@Lusito I think the post from joshsmith is important, wouldn't it make sense to update the specification? |
Will be fixed in the next version. For the record: I don't think it's a good idea, because people easily misunderstand this and think they can call it multiple times. |
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onMessage
The actual
browser.runtime.onMessage.addListener
accepts 3 arguments:, message, sender, sendResponse. However, the current implementation only accepts 2 arguments: message, senderThe text was updated successfully, but these errors were encountered: