feat: add webContents.getPrintersAsync()
(#31023)
This deprecates the synchronous and blocking `webContents.getPrinters()` function and introduces `webContents.getPrintersAsync()`, which is asynchronous and non-blocking. Signed-off-by: Darshan Sen <darshan.sen@postman.com>
This commit is contained in:
parent
b936f5e14a
commit
8f51d3e1bf
5 changed files with 70 additions and 4 deletions
|
@ -391,6 +391,17 @@ WebContents.prototype.getPrinters = function () {
|
|||
}
|
||||
};
|
||||
|
||||
WebContents.prototype.getPrintersAsync = async function () {
|
||||
// TODO(nornagon): this API has nothing to do with WebContents and should be
|
||||
// moved.
|
||||
if (printing.getPrinterListAsync) {
|
||||
return printing.getPrinterListAsync();
|
||||
} else {
|
||||
console.error('Error: Printing feature is disabled.');
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
WebContents.prototype.loadFile = function (filePath, options = {}) {
|
||||
if (typeof filePath !== 'string') {
|
||||
throw new Error('Must pass filePath as a string');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue