Questions tagged [eventemitter]

An event emitter is a platform for triggering and listening for events.

An event emitter is a platform for triggering and listening for events. Different libraries offer different implementations and for different purposes.

960 questions
0
votes
1 answer

NodeJS EventEmitter

I'm using a modular setup where Socket.IO is no part of my application or routes - but in an external module. I have a PHP script that receives data and then updates the database. I've set it up to send a cURL request to the node application, and…
ash
  • 1,224
  • 3
  • 26
  • 46
0
votes
1 answer

Execute when both(!) events fire .on('end')

I have a node app that reads two files as streams. I use event.on('end') to then work with the results. The problem is I don't really know how I can wait for BOTH events to trigger 'end'. What I have now is: reader1.on('end', function(){ …
gattermeier
  • 471
  • 1
  • 5
  • 11
0
votes
0 answers

Extending another node module but intercepting results & emitters

I have my own module (lets call it klinquist) that uses restler for its rest calls. Currently, I'm just extending it: var rest = require('restler'); klinquist.prototype.rest = rest; In my node app, I simply call…
klinquist
  • 246
  • 1
  • 4
  • 15
0
votes
2 answers

Listen to Reflux actions outside of stores

I'm trying to figure out how to fit ajax calls into the flux/reflux way of doing things. From the scraps of info I've found online it seems correct to separate the API logic from the stores. Starting there, I've created a client API that makes…
captDaylight
  • 2,224
  • 4
  • 31
  • 42
0
votes
0 answers

xml read by event emitter and saved promise way

I got library xml-stream which reads xml from stream and emits 'endElement' event on every interesting tag, under the hood it uses node-expat which is also written event way On every tag I want to save it to database with bookshelf/knex ORM which…
madeuz
  • 201
  • 2
  • 3
0
votes
0 answers

Browserify EventEmitter issue

I am working on an assets loader, this class inherits EventEmitter for progress and over events. I use it this way: // LOAD INITIAL ASSETS & START GAME AFTER assets.on('over',function() { // START GAME HOB.start(); }); …
0
votes
1 answer

Capturing events from another module with on nodejs

I am using a module called request(https://www.npmjs.com/package/request) to perform series of http requests on my application. Now I am trying to add a logging functionality to it but cannot seem to figure out how to capture the events from the…
0
votes
1 answer

Emit an event to a child object

I'm writing a nodejs module and trying bind an event emitter to "scrappy.get". It seems that I can only bind it to "scrappy" .... so "scrappy.get(key).on('complete'...." does not work. How do I send the event to the child object 'get'? My NodeJS…
klinquist
  • 246
  • 1
  • 4
  • 15
0
votes
1 answer

Adding event listener on instance, not function

See example below. I am trying to trigger an event on a. var events = require("events"); function foo() { this.on("ping", function() { console.log("bar!"); }) } foo.prototype = new events.EventEmitter(); var a = new foo(); var b =…
Marcus Johansson
  • 2,626
  • 2
  • 24
  • 44
0
votes
0 answers

I think I have a memory leak in Event Emitter, how should I be cleaning up global variables?

I've noticed some odd activity in my MongoDB collection and I believe that some events I've received back to back are sharing global variables. For instance, I had a document that I removed prematurely from the collection, then I received an event…
JoshJoe
  • 1,482
  • 2
  • 17
  • 35
0
votes
2 answers

One object doesn't listen to an event emitted on another object

Trying to make an object emitting and receiving events: var events = require('events'), util = require('util'); function Obj(){ events.EventEmitter.call( this ); // what does this line? } util.inherits( Obj, events.EventEmitter ); var o =…
Nik Terentyev
  • 2,270
  • 3
  • 16
  • 23
0
votes
1 answer

Prototyping Array to inherit from EventEmitter in Node.js

Am currently working on a project where I require to inherit from EventEmitter. I need an array to emit events on certain cases, say, when some length has been exceeded. I used this snippet: var events = require('events'); Array.prototype.__proto__…
gochomugo
  • 25
  • 6
0
votes
2 answers

Node.JS > save results from event emitter

This is probably a horrible noob question, but I am doing something wrong here. Why won't my result variable not save outside of .on()? How would I return the results of csvConverter.on ? var res = '';…
gattermeier
  • 471
  • 1
  • 5
  • 11
0
votes
1 answer

Best method to share eventemitter2 globally

I'm not new to programming, but new to NodeJS. I have a rather complex project that is now several modules deep, of course all rooted in app.js, similar to the following map: App.js requires('Module_a') requires('Module_b') …
0
votes
1 answer

Node emitter : how to properly design event listeners

I'm learning node: Looking inside the EventEmitter, by default it executes callbacks by passing the emitter as this to the event listener, such that within your event listener function, this refers to the EventEmitter object. I'm somewhat confused…
asking
  • 1,435
  • 3
  • 13
  • 21