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
358
votes
22 answers

possible EventEmitter memory leak detected

I am getting following warning: (node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit. Trace: at EventEmitter. (events.js:139:15) at…
Riz
  • 9,703
  • 8
  • 38
  • 54
282
votes
7 answers

Delegation: EventEmitter or Observable in Angular

I am trying to implement something like a delegation pattern in Angular. When the user clicks on a nav-item, I would like to call a function which then emits an event which should in turn be handled by some other component listening for the…
the_critic
  • 12,720
  • 19
  • 67
  • 115
147
votes
4 answers

How pass 2 parameters to EventEmitter in Angular?

I have in my component an EventEmitter but I can't compile it because it throws the error: Supplied parameters do not match any signature of call target My component: @Output() addModel = new EventEmitter(); saveModel($event, make, name) { …
LorenzoBerti
  • 6,704
  • 8
  • 47
  • 89
96
votes
6 answers

Node.js - inheriting from EventEmitter

I see this pattern in quite a few Node.js libraries: Master.prototype.__proto__ = EventEmitter.prototype; (source here) Can someone please explain to me with an example, why this is such a common pattern and when it's handy?
jeffreyveon
  • 13,400
  • 18
  • 79
  • 129
93
votes
4 answers

Child listens for parent event in Angular 2

In angular docs there is a topic about listening for child events from parents. That's fine. But my purpose is something reverse!. In my app there is an 'admin.component' that holds the layout view of admin page (sidebar menu,task bar, status…
Hamed Hamedi
  • 1,461
  • 1
  • 10
  • 19
91
votes
6 answers

vue 3 emit warning " Extraneous non-emits event listeners"

I am trying to emit data from child to parent using the composition API I get the following warning. [Vue warn]: Extraneous non-emits event listeners (updatedcount) were passed to component but could not be automatically inherited because component…
Fanna1119
  • 1,878
  • 4
  • 24
  • 30
87
votes
4 answers

Pass parameters with EventEmitter

I have a directive to initializes a jQueryUI sortable on a DOM element. The jQueryUI sortable also has a set of callback events that trigger on certain actions. For example, when you start or stop sorting elements. I'd like to pass the return…
Vivendi
  • 20,047
  • 25
  • 121
  • 196
84
votes
12 answers

Is there any EventEmitter in browser side that has similar logic in NodeJS?

It is so easy to use eventEmitter in node.js: var e = new EventEmitter(); e.on('happy', function(){console.log('good')}); e.emit('happy'); Any client side EventEmitter in browser native?
Xin
  • 33,823
  • 14
  • 84
  • 85
56
votes
8 answers

NodeJS : How to debug "EventEmitter memory leak detected. 11 listeners added"

How can I debug my application which throw this error: (node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit. Trace at Socket.EventEmitter.addListener (events.js:160:15) …
Ifnot
  • 4,914
  • 4
  • 33
  • 47
50
votes
3 answers

React Hooks useState+useEffect+event gives stale state

I'm trying to use an event emitter with React useEffect and useState, but it always gets the initial state instead of the updated state. It works if I call the event handler directly, even with a setTimeout. If I pass the value to the useEffect()…
Tony R
  • 11,224
  • 23
  • 76
  • 101
45
votes
2 answers

Difference b/w event.on() and event.once() in nodejs

I'm testing the plus_one app, and while running it, I just wanted to clarify my concepts on event.once() and event.on() This is plus_one.js > process.stdin.resume(); process.stdin.on('data',function(data){ var number; try{ …
Anathema.Imbued
  • 3,271
  • 4
  • 17
  • 18
42
votes
2 answers

How to properly remove event listeners in node js eventemitter

I have a set up with a GET and a POST route, the idea being that POSTing to the route triggers an event, and the GET route is a server-sent eventstream which fires each time the POSTed event is triggered... however, i think i've done something wrong…
coffeedoughnuts
  • 505
  • 1
  • 5
  • 12
37
votes
11 answers

Concatenate two (or n) streams

2 streams: Given readable streams stream1 and stream2, what's an idiomatic (concise) way to get a stream containing stream1 and stream2 concatenated? I cannot do stream1.pipe(outStream); stream2.pipe(outStream), because then the stream contents are…
Jo Liss
  • 30,333
  • 19
  • 121
  • 170
33
votes
3 answers

How to unsubscribe from EventEmitter in Angular 2?

export declare class EventEmitter extends Subject { /** * Creates an instance of [EventEmitter], which depending on [isAsync], * delivers events synchronously or asynchronously. */ constructor(isAsync?: boolean); …
tom10271
  • 4,222
  • 5
  • 33
  • 62
31
votes
2 answers

How to subscribe to event emitter once?

// Part of service public someEvent: EventEmitter = new EventEmitter(); .... // Component @Component({ selector: 'some-component', template: `...` }) export class SomeComponent { constructor(public service: Service) { …
Eggy
  • 4,052
  • 7
  • 23
  • 39
1
2 3
63 64