orca icon indicating copy to clipboard operation
orca copied to clipboard

'ready' call back don't response.

Open WintonWL opened this issue 5 years ago • 0 comments

When I used orca.run, the call back wasn't called. After checking the orca codes, I found the problem: electron app had been called 'ready' before orca.run, so orca.run call back is invalid.

Those modified codes in index.js createApp work for me:

function createApp (_opts) {
  initApp(app, ipcMain)

  const opts = coerceOpts(_opts)
  let win = null
  let index = null

  let readyCallback = () => {
    win = new BrowserWindow(opts._browserWindowOpts)

    if (opts.debug) {
      win.openDevTools()
    }

    win.on('closed', () => {
      win = null
      index.destroy()
    })

    createIndex(opts.component, opts, (_index) => {
      index = _index
      win.loadURL(`file://${index.path}`)
    })

    win.webContents.once('did-finish-load', () => {
      run(app, win, ipcMain, opts)
    })
  }

  if (app.isReady()) {
    readyCallback();
  } else {
    app.on('ready', readyCallback);
  }
  
  return app
}

WintonWL avatar Aug 07 '20 02:08 WintonWL