Skip to content

Commit

Permalink
changed onReceiveAndSend listener to on
Browse files Browse the repository at this point in the history
  • Loading branch information
Akumzy committed May 17, 2019
1 parent 5027a11 commit fbb0078
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Binary file removed example/compired-go-binary
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ipc-node-go",
"version": "0.1.8",
"version": "0.1.9",
"description": "An IPC implementation between Node and its child process (Golang binary) using the stdin / stdout as the transport.",
"main": "dist/index.js",
"scripts": {
Expand Down
8 changes: 5 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class IPC extends EventEmitter {
* and will wait another 20 seconds for reply via `pong` event name
* else it will kill it's process.
*/
this.on('ping', () => this.send('pong'))
this.onReceiveAnSend('ping', (channel) => {
this.send(channel)
})
}
/**
* Start the child process
Expand Down Expand Up @@ -69,7 +71,7 @@ class IPC extends EventEmitter {
this.send('___EXIT___', null)
this.closed = true
this.go.kill()
} catch (error) {}
} catch (error) { }
}
/**
* Send message to `Golang` process
Expand Down Expand Up @@ -146,7 +148,7 @@ class IPC extends EventEmitter {
cb: (channel: string, data: any) => void
) {
let channel = event + '___RS___'
this.once(event, data => {
this.on(event, data => {
if (typeof cb === 'function') cb(channel, data)
})
}
Expand Down

0 comments on commit fbb0078

Please sign in to comment.