in Technology by

What is the reactor design pattern used in Node.js?

1 Answer

0 votes
by

The reactor pattern is used for maintaining non-blocking I/O operations in Node.js. It attaches a callback function (a handler) to each I/O operation. The handler is then submitted to a demultiplexer at the time of request creation.

Demultiplexer collects every I/O request made in the application and queues them as events in a queue. This is what we call the event queue. After queuing the event, the demultiplexer returns the control of the application thread.

Meanwhile, the event loop iterates over each event in the event queue, and invokes the attached callback to handle the event response.

This is the reactor pattern used by Node.js.

Related questions

0 votes
0 votes
0 votes
    How can we handle uncaught exceptions in Node.js?...
asked Jan 25, 2021 in Technology by JackTerrance
0 votes
    What is the difference between readFile and createReadStream functions in Node.js?...
asked Jan 25, 2021 in Technology by JackTerrance
0 votes
    What are the uses of EventEmitter in Node.js?...
asked Jan 25, 2021 in Technology by JackTerrance
0 votes
0 votes
    What are the differences between Node.js and Javascript?...
asked Jan 25, 2021 in Technology by JackTerrance
0 votes
    how to parse query string in node.js lambda?...
asked Dec 10, 2020 in Technology by JackTerrance
0 votes
    Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    Which of the below is not a valid design pattern? (a) Singleton (b) Factory (c) Command (d) Java I got ... Java Beans & JDBC of Java Select the correct answer from above options...
asked Feb 22, 2022 in Education by JackTerrance
0 votes
    Which of the below is not a valid classification of design pattern? (a) Creational patterns (b) Structural patterns ... & JDBC of Java Select the correct answer from above options...
asked Feb 22, 2022 in Education by JackTerrance
0 votes
    Which design pattern provides a single class which provides simplified methods required by client and delegates call to ... of Java Select the correct answer from above options...
asked Feb 22, 2022 in Education by JackTerrance
0 votes
    Which design pattern ensures that only one object of particular class gets created? (a) Singleton pattern (b) Filter ... JDBC of Java Select the correct answer from above options...
asked Feb 22, 2022 in Education by JackTerrance
0 votes
    Which design pattern suggests multiple classes through which request is passed and multiple but only relevant classes carry ... of Java Select the correct answer from above options...
asked Feb 22, 2022 in Education by JackTerrance
...