Created
February 27, 2023 00:02
-
-
Save dfahlander/71d04fc3995d11bafa41236563dce229 to your computer and use it in GitHub Desktop.
Electron 23 liveQuery workaround
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This module shall be imported from the main node module in electron. | |
// The BrowserWindows shall instead import 'workaround-renderer.ts' | |
// NOTE: This gist shall NOT be used in Electron versions where https://github.com/electron/electron/issues/37417 is resolved | |
import { ipcMain } from "electron"; | |
import { BrowserWindow } from "electron"; | |
if (typeof BroadcastChannel !== "undefined") { | |
// We're on electron version 23 with BroadcastChannel support in node | |
ipcMain.on("dexie-storagemutated", (event, json) => { | |
BrowserWindow.getAllWindows().forEach((window) => { | |
if (window.webContents.id !== event.sender.id) { | |
try { | |
window.webContents.send("dexie-storagemutated", json); | |
} catch {} | |
} | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment