Can an event be monitored multiple times in electron?

look at the code of electron

class IncomingMessage extends EventEmitter {

    // Docs: http://electron.atom.io/docs/api/incoming-message

    /**
     * Emitted when a request has been canceled during an ongoing HTTP transaction.
     */
    on(event: "aborted", listener: Function): this;
    once(event: "aborted", listener: Function): this;
    addListener(event: "aborted", listener: Function): this;
    removeListener(event: "aborted", listener: Function): this;
    /**
     * The data event is the usual method of transferring response data into
     * applicative code.
     */
    on(event: "data", listener: (
                                 /**
                                  * A chunk of response body"s data.
                                  */
                                 chunk: Buffer) => void): this;
    once(event: "data", listener: (
                                 /**
                                  * A chunk of response body"s data.
                                  */
                                 chunk: Buffer) => void): this;
    addListener(event: "data", listener: (
                                 /**
                                  * A chunk of response body"s data.
                                  */
                                 chunk: Buffer) => void): this;
    removeListener(event: "data", listener: (
                                 /**
                                  * A chunk of response body"s data.
                                  */
                                 chunk: Buffer) => void): this;
    /**
     * Indicates that response body has ended.
     */
    on(event: "end", listener: Function): this;
    once(event: "end", listener: Function): this;
    addListener(event: "end", listener: Function): this;
    removeListener(event: "end", listener: Function): this;
    /**
     * error Error - Typically holds an error string identifying failure root cause.
     * Emitted when an error was encountered while streaming response data events. For
     * instance, if the server closes the underlying while the response is still
     * streaming, an error event will be emitted on the response object and a close
     * event will subsequently follow on the request object.
     */
    on(event: "error", listener: Function): this;
    once(event: "error", listener: Function): this;
    addListener(event: "error", listener: Function): this;
    removeListener(event: "error", listener: Function): this;
    headers: any;
    httpVersion: string;
    httpVersionMajor: number;
    httpVersionMinor: number;
    statusCode: number;
    statusMessage: string;
  }

API provided for incoming messages

currently the program is a program that interacts with telet, and the output is rendered to the web page, so on ("data") is already used and cannot be removed.

if you remove the page, you will not output contiguous content, and you must keep listening.

now because you want to do a trigger, you need to listen for the "data" event" in another class

print with eventNames () , you can see ["end"," finish","_ socketEnd", "data"]

so my question is, how do I add another listening event to "data"?

has used addListener , but the print event name is still ["end"," finish","_ socketEnd", "data"] , so you can"t remove it with removeListener .

solve

Mar.19,2021
Menu