remove sendSync

This commit is contained in:
lnrdnl committed 2024-02-20 15:24:01 +01:00
1 parent 6f4d96c11b
commit fd80a831e1
3 files changed
+1 -9

No files matched your search

@@ -16,7 +16,6 @@ When sending events from renderer to main, you access the `window.mainApi` objec
Here are the supported functions for mainApi: Here are the supported functions for mainApi:
- `send`: Send an event to main. - `send`: Send an event to main.
- `sendSync`: Send an event to main. It can be used when receiving a return value. The UI may be frozen until the operation is complete.
- `on`: A listener to receive events sent by main. - `on`: A listener to receive events sent by main.
- `once`: A listener to receive events sent by main. (Handle only one call) - `once`: A listener to receive events sent by main. (Handle only one call)
- `off`: Remove an event listener - `off`: Remove an event listener
-7
View File
@@ -12,13 +12,6 @@ contextBridge.exposeInMainWorld('mainApi', {
throw new Error(`Unknown ipc channel name: ${channel}`) throw new Error(`Unknown ipc channel name: ${channel}`)
} }
}, },
sendSync: (channel: string, ...data: any[]): any => {
if (mainAvailChannels.includes(channel)) {
return ipcRenderer.sendSync.apply(null, [channel, ...data])
}
throw new Error(`Unknown ipc channel name: ${channel}`)
},
on: (channel: string, listener: (event: IpcRendererEvent, ...args: any[]) => void): void => { on: (channel: string, listener: (event: IpcRendererEvent, ...args: any[]) => void): void => {
if (rendererAvailChannels.includes(channel)) { if (rendererAvailChannels.includes(channel)) {
ipcRenderer.on(channel, listener) ipcRenderer.on(channel, listener)
+1 -1
View File
@@ -21,7 +21,7 @@ onMounted((): void => {
}) })
const getApplicationVersionFromMainProcess = (): void => { const getApplicationVersionFromMainProcess = (): void => {
appVersion.value = window.mainApi.sendSync('msgRequestGetVersion') window.mainApi.invoke('msgRequestGetVersion').then((result: string) => appVersion.value = result)
} }
const handleChangeTheme = (): void => { const handleChangeTheme = (): void => {