Browse Source
Merge pull request #442 from gre/polish-boot-bug
console.log of commands in console + don't crash on race
master
Meriadec Pillet
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
7 additions and
7 deletions
-
src/helpers/ipc.js
-
src/internals/index.js
-
src/renderer/init.js
|
|
@ -47,17 +47,20 @@ function ipcRendererSendCommand<In, A>(id: string, data: In): Observable<A> { |
|
|
|
if (requestId !== msg.requestId) return |
|
|
|
switch (msg.type) { |
|
|
|
case 'NEXT': |
|
|
|
console.log('<= COMMAND next', msg) |
|
|
|
if (msg.data) { |
|
|
|
o.next(msg.data) |
|
|
|
} |
|
|
|
break |
|
|
|
|
|
|
|
case 'COMPLETE': |
|
|
|
console.log('<= COMMAND complete', msg) |
|
|
|
o.complete() |
|
|
|
ipcRenderer.removeListener('command-event', handleCommandEvent) |
|
|
|
break |
|
|
|
|
|
|
|
case 'ERROR': |
|
|
|
console.warn('<= COMMAND error', msg) |
|
|
|
o.error(msg.data) |
|
|
|
ipcRenderer.removeListener('command-event', handleCommandEvent) |
|
|
|
break |
|
|
@ -70,6 +73,8 @@ function ipcRendererSendCommand<In, A>(id: string, data: In): Observable<A> { |
|
|
|
|
|
|
|
ipcRenderer.send('command', { id, data, requestId }) |
|
|
|
|
|
|
|
console.log('=> COMMAND', { id, data, requestId }) |
|
|
|
|
|
|
|
return unsubscribe |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
@ -9,7 +9,6 @@ process.title = 'Internal' |
|
|
|
const subscriptions = {} |
|
|
|
|
|
|
|
process.on('message', m => { |
|
|
|
console.log(m) |
|
|
|
if (m.type === 'command') { |
|
|
|
const { data, requestId, id } = m.command |
|
|
|
const cmd = commands.find(cmd => cmd.id === id) |
|
|
@ -56,4 +55,4 @@ process.on('message', m => { |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
console.log('Internal process is ready!') |
|
|
|
console.log('Internal process is up!') |
|
|
|
|
|
@ -6,7 +6,6 @@ import { render } from 'react-dom' |
|
|
|
import { AppContainer } from 'react-hot-loader' |
|
|
|
import createHistory from 'history/createHashHistory' |
|
|
|
import moment from 'moment' |
|
|
|
import { delay } from 'helpers/promise' |
|
|
|
|
|
|
|
import createStore from 'renderer/createStore' |
|
|
|
import events from 'renderer/events' |
|
|
@ -73,10 +72,7 @@ async function init() { |
|
|
|
if (isMainWindow) { |
|
|
|
events({ store, locked }) |
|
|
|
|
|
|
|
const libcoreVersion = await Promise.race([ |
|
|
|
libcoreGetVersion.send().toPromise(), |
|
|
|
delay(10000).then(() => Promise.reject(new Error("timeout: can't load libcore"))), |
|
|
|
]) |
|
|
|
const libcoreVersion = await libcoreGetVersion.send().toPromise() |
|
|
|
console.log('libcore', libcoreVersion) |
|
|
|
} |
|
|
|
} |
|
|
|