11import { Worker } from 'node:worker_threads' ;
22
33import { PowerSyncDatabase } from '@powersync/node' ;
4- import { app , BrowserWindow } from 'electron' ;
4+ import { app , BrowserWindow , ipcMain } from 'electron' ;
55import { AppSchema } from './powersync' ;
66import { default as Logger } from 'js-logger' ;
77
@@ -12,7 +12,7 @@ const database = new PowerSyncDatabase({
1212 schema : AppSchema ,
1313 database : {
1414 dbFilename : 'test.db' ,
15- openWorker ( filename , options ) {
15+ openWorker ( _ , options ) {
1616 return new Worker ( new URL ( './worker.ts' , import . meta. url ) , options ) ;
1717 } ,
1818 } ,
@@ -50,7 +50,12 @@ const createWindow = (): void => {
5050// This method will be called when Electron has finished
5151// initialization and is ready to create browser windows.
5252// Some APIs can only be used after this event occurs.
53- app . on ( 'ready' , createWindow ) ;
53+ app . whenReady ( ) . then ( ( ) => {
54+ ipcMain . handle ( 'get' , async ( _ , sql : string , args : any [ ] ) => {
55+ return await database . get ( sql , args ) ;
56+ } ) ;
57+ createWindow ( ) ;
58+ } ) ;
5459
5560// Quit when all windows are closed, except on macOS. There, it's common
5661// for applications and their menu bar to stay active until the user quits
0 commit comments