feat: promisify win.capturePage() (#15743)

* feat: promisify win.capturePage

* mark optional arg correctly

* Add to breaking changes doc

* properly deprecate win.capturePage

* remove change from api-contract

* document both callback and promise versions

* address docs feedback

* update promisification progress doc
This commit is contained in:
Shelley Vohr 2018-11-27 23:50:53 -05:00 committed by GitHub
parent 73fbb69c50
commit 41c2685204
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 74 additions and 38 deletions

View file

@ -318,13 +318,19 @@ WebContents.prototype._init = function () {
NavigationController.call(this, this)
// Every remote callback from renderer process would add a listenter to the
// render-view-deleted event, so ignore the listenters warning.
// render-view-deleted event, so ignore the listeners warning.
this.setMaxListeners(0)
const nativeCapturePage = this.capturePage
this.capturePage = function (rect, cb) {
return deprecate.promisify(nativeCapturePage.call(this, rect), cb)
}
// Dispatch IPC messages to the ipc module.
this.on('ipc-message', function (event, [channel, ...args]) {
ipcMain.emit(channel, event, ...args)
})
this.on('ipc-message-sync', function (event, [channel, ...args]) {
Object.defineProperty(event, 'returnValue', {
set: function (value) {
@ -338,6 +344,7 @@ WebContents.prototype._init = function () {
this.on('ipc-internal-message', function (event, [channel, ...args]) {
ipcMainInternal.emit(channel, event, ...args)
})
this.on('ipc-internal-message-sync', function (event, [channel, ...args]) {
Object.defineProperty(event, 'returnValue', {
set: function (value) {