Wednesday, 10 May 2017

Why does this act as a singleton in NodeJS

Why does this act as a singleton in NodeJS, how does it work?

const io = require('socket.io')();

const singleton = module.exports = io;

In essence, if I import this file more than once, I get the first instantiated socket.io instance.



via Seyi Adekoya

No comments:

Post a Comment