R
Reactiflux

BIOLOGY SCIENCE – 04-58 Aug 2

BIOLOGY SCIENCE – 04-58 Aug 2

RRelativPerspektiv8/2/2022
1. how can i communicate between js files via events ? im thinking something like this
// emitter file
const events = require('events');
const event = new events();

module.exports = event;

event.emit('myEvent', 'some data');

// some other file which i want to listen to
const event = require('path/to/emitter');
event.addListener('myEvent', (e) => console.log(e));
// emitter file
const events = require('events');
const event = new events();

module.exports = event;

event.emit('myEvent', 'some data');

// some other file which i want to listen to
const event = require('path/to/emitter');
event.addListener('myEvent', (e) => console.log(e));
2. what is the best way to communicate between js files. condition: not primarily by module.exports, like it should not be the main thing which transports the data but it can help in doing so like i did in case 1.
UUUnknown User8/2/2022
Message Not Public
Sign In & Join Server To View

Looking for more? Join the community!

R
Reactiflux

BIOLOGY SCIENCE – 04-58 Aug 2

Join Server