Merge pull request #26835 from gjurgens/node-ipc-unsubscribe-server-events

[@types/node-ipc]: Adding 'off' (unsubcribe) method to server class
This commit is contained in:
Paul van Brenk
2018-06-26 10:32:56 -07:00
committed by GitHub
2 changed files with 6 additions and 1 deletions
+5 -1
View File
@@ -1,6 +1,6 @@
// Type definitions for node-ipc 9.1
// Project: http://riaevangelist.github.io/node-ipc/
// Definitions by: Arvitaly <https://github.com/arvitaly>
// Definitions by: Arvitaly <https://github.com/arvitaly>, gjurgens <https://github.com/gjurgens>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import { Socket } from "net";
@@ -178,6 +178,10 @@ declare namespace NodeIPC {
*/
on(event: "data", callback: (buffer: Buffer) => void): Client;
emit(event: string, value?: any): Client;
/**
* Unbind subscribed events
*/
off(event: string, handler: any): Client;
}
interface Server extends Client {
/**
+1
View File
@@ -63,3 +63,4 @@ declare const socket: Socket;
ipc.server.emit(socket, myBuffer);
ipc.server.emit([10, 20, 30]);
ipc.server.emit({ address: 'localhost', port: 8000 }, "message", { id: ipc.config.id, message: 'Goodbye' });
ipc.server.off("error", "*");