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
feat: add WebContents.ipc #34959
feat: add WebContents.ipc #34959
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the API's current form, I find it a bit confusing for users without historical perspective that the win.webContents.ipc
object would be separate from the existing win.webContents.send
API.
My initial thought was to alias the IPC command to win.webContents.ipc.send
, but then the object description gains a new dimension of complexity (e.g. can't be reduced to a one-line "an IpcMain instance").
Yeah, it seems reasonable to expect |
We should deprecated |
@miniak I don't see any particular reason to deprecate them, they're minimal overhead and deprecating/removing them would break apps for no particular reason. I'd be fine adding a note in the docs about the new |
btw I tried doing this before in #16420 and it got rejected :) |
ok, makes sense |
@miniak yeah, i remember that! thanks for the link. i now think i was wrong 😅 |
any plans to backport, at least to 20-x-y? |
I don't think this is worth backporting. It's easily polyfillable. |
|
shouldn't the |
I feel a little awkward about adding the
and this would add:
all of which would be duplicating functionality. Does this seem worth it @erickzhao? I do agree that |
@nornagon I don't think it's worth adding those methods. Moreover |
are you sure? basic |
Co-authored-by: Samuel Attard <sam@electronjs.org>
@miniak yeah i guess it's not super trivial to do that said, Electron 20 will be going stable in about 2 weeks, and I don't feel super great about that short of a runway for this feature. given this is just ergonomic and doesn't add any new functionality, I'm erring on the side of not backporting. |
API LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API LGTM
i'm in agreement that #34959 (comment) is a case where drawbacks outweigh benefits, and that we shouldn't backport here.
Release Notes Persisted
|
/trop run backport-to 21-x-y |
The backport process for this PR has been manually initiated - sending your PR to |
I have automatically backported this PR to "21-x-y", please check out #35231 |
feat: add WebContents.ipc (electron#34959) Co-authored-by: Jeremy Rose <jeremya@chromium.org>
Description of Change
This adds a new API,
WebContents.ipc
, which works likeipcMain
but isscoped to only IPC messages sent from a single WebContents.
This allows a developer to more ergonomically communicate with a specific
WebContents, replacing either "source checks" or "channel checks" with a
"declarative" source/channel check.
e.g. without:
refactored to use the new
WebContents.ipc
API introduced in this PR:I believe this is clearer and less error-prone than the existing methods for
accomplishing the same result.
Also adds an analogous API to
WebFrameMain.ipc
.Checklist
npm test
passesRelease Notes
Notes: Added new
WebContents.ipc
andWebFrameMain.ipc
APIs.