docs: Make ipcRenderer and ipcMain listener API docs consistent (#44711)

* docs: Make ipcRenderer and ipcMain listener API docs consistent

Co-authored-by: Will Anderson <will@itsananderson.com>

* test: add some unit tests for ipcRenderer/ipcMain listener behavior

Co-authored-by: Will Anderson <will@itsananderson.com>

* fix: Mark on/off methods as primary and addListener/removeListener as aliases

Co-authored-by: Will Anderson <will@itsananderson.com>

* fix: clear all listeners before running ipcMain removeAllListeners tests

Co-authored-by: Will Anderson <will@itsananderson.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Will Anderson <will@itsananderson.com>
This commit is contained in:
trop[bot] 2024-11-19 09:47:45 +01:00 committed by GitHub
parent d5ece2a033
commit 3764c4d0b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 86 additions and 10 deletions

View file

@ -48,7 +48,8 @@ Listens to `channel`, when a new message arrives `listener` would be called with
* `event` [IpcRendererEvent][ipc-renderer-event]
* `...args` any[]
Alias for [`ipcRenderer.removeListener`](#ipcrendererremovelistenerchannel-listener).
Removes the specified `listener` from the listener array for the specified
`channel`.
### `ipcRenderer.once(channel, listener)`
@ -76,14 +77,13 @@ Alias for [`ipcRenderer.on`](#ipcrendereronchannel-listener).
* `event` [IpcRendererEvent][ipc-renderer-event]
* `...args` any[]
Removes the specified `listener` from the listener array for the specified
`channel`.
Alias for [`ipcRenderer.off`](#ipcrendereroffchannel-listener).
### `ipcRenderer.removeAllListeners(channel)`
### `ipcRenderer.removeAllListeners([channel])`
* `channel` string
* `channel` string (optional)
Removes all listeners, or those of the specified `channel`.
Removes all listeners from the specified `channel`. Removes all listeners from all channels if no channel is specified.
### `ipcRenderer.send(channel, ...args)`