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

Node.js EventEmitter error

I have an error when trying to inherit EvenEmitter /* Consumer.js */ var EventEmitter = require('events').EventEmitter; var util = require('util'); var Consumer = function() {}; Consumer.prototype = { // ... functions ... findById:…
jtomasrl
  • 1,430
  • 3
  • 13
  • 22
0
votes
1 answer

Inheriting Node.js' eventemitter fails

I'm trying to add the event listener to my class, but it fails, telling me the object has no 'on' method. Here's the class in its own file: var events = require('events'); var util = require('util'); var Motion = function Motion (app) { …
Jelle De Loecker
  • 20,999
  • 27
  • 100
  • 142
0
votes
1 answer

Best way using events in node.js

Which is the best approach for listening/launching events in node.js? I've been testing event launching and listening in node.js by extending the model with EventEmitter and I'm wondering if it has sense this approach since the events are only…
Endymion
  • 782
  • 1
  • 10
  • 24
0
votes
2 answers

Node.js attaching event handlers on new

In a Node.js-based project, I have a couple objects: EmitterA EmitterB Consumer In Consumer's constructor, I have the following: var a = new EmitterA(); a.on('someEvent', someEventHandler); In EmitterA's constructor, I have the following: var…
Brad
  • 159,648
  • 54
  • 349
  • 530
-1
votes
1 answer

wait for the emitter listeners to be set before fulfilling the promise

I'm working with some external lib that provide some function that returns instance of the EventEmitter object. Those functions needs to be invoked in a certain order and are implemented using nested callbacks in the library example. I would like to…
Maxime Oger
  • 160
  • 1
  • 8
-1
votes
1 answer

Is there a way to pass a value into an Interceptor class?

For background: I have an interceptor that clones a request and inserts a bearer token, I want to add another field to this newRequest called: id with a value I grabbed from an eventEmitter in another class: AppComponent I have value but I can't…
-1
votes
1 answer

why this code is only printing the first statement as output

var events = require('events') var eventEmitter = new events.EventEmitter(); var fn1 = function() { console.log("first fn executed on triggering first event ") eventEmitter.emit('fn1') } eventEmitter.on("event1",…
Ochaoash
  • 121
  • 1
  • 1
  • 10
-1
votes
1 answer

How to use this function based Event Emitter?

In this old answer is there the below function based event emitter. Maybe it is super obvious how to use it, but not for me, so I would really appreciate if someone could make a hello world example with it. Can anyone figure out how to use…
Sandra Schlichting
  • 25,050
  • 33
  • 110
  • 162
-1
votes
3 answers

How to emit a message across components in Angular

How can I emit a string value across unrelated components in Angular? I have a login component in which when the user successfully logs in to my backend API, the HTML response will include their username. I then want this username to be emitted to a…
Moonket
  • 11
  • 6
-1
votes
1 answer

EventEmitter cannot emit an object with KeyValuePair property in Angular

I want to fill and emit an object that has 2 property; 1. string 2.array of KeyValuePair by EventEmitter in Angular version 9. My object's class: import { KeyValuePair } from './keyValuePair'; export class SelectedApiCall { …
-1
votes
1 answer

How did many libraries make their own event listener and their own events, like in the leaflet library?

In many libraries, like leaflet, they have their own events, like the 'resize', or 'zoom' events, you can see them at here, they also have their own events objects, with custom properties, and those events object don't have the properties of DOM…
-1
votes
1 answer

how to refresh UI without reloading the page in Angular

I have a multiple charts in my page and I'm trying to make a delete call but some reason my chart UI is not updating immediately when I click the delete button. I always need to refresh the browser in order to see the changes. I uploaded the full…
user9436741
-1
votes
1 answer

Can I use a single BehaviorSubject for multiple events?

In Angular 8, I use the following approach in order to refresh Details page after a new record added: EventProxyService export class EventProxyService { private eventTracker = new BehaviorSubject(undefined); /* Allows subscription to…
user5871859
-1
votes
1 answer

How to set Behaviour Subject initial value retrieved from Database?

I pass data from parent to its child components via BehaviorSubject as the following approach (I simplified the approach for brevity): const subject = new BehaviorSubject(undefined); // subscriber A subject.subscribe((data) => { if(data !==…
user5871859
-1
votes
1 answer

unable to remove listener from mongodb change stream 'change' event

I figured the mongodb change stream extends the EventEmitter class, so I tried removing events I installed by using the removeListener function. After calling removeListener on the change stream it still fired on change. May be I'm just using the…
lasse
  • 95
  • 8
1 2 3
63
64