Browse Source

console.log of commands in console + don't crash on race

master
Gaëtan Renaudeau 7 years ago
parent
commit
4a0276d951
  1. 5
      src/helpers/ipc.js
  2. 3
      src/internals/index.js
  3. 6
      src/renderer/init.js

5
src/helpers/ipc.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
})
}

3
src/internals/index.js

@ -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
src/renderer/init.js

@ -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)
}
}

Loading…
Cancel
Save