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
30
votes
4 answers

Angular component: Can I use an Observable instead EventEmitter as @Output() property?

[angular 2.4.5] I tried and it seems to work like an EventEmitter: My component from outside: Inside the component: @Output() visibleTransitionEnd: Observable observer:…
bertrandg
  • 3,147
  • 2
  • 27
  • 35
29
votes
2 answers

angular 2: using a service to broadcast an event

I'm trying to get a button click in one component to put focus on an element on another component. (Frankly, I don't understand why this must be so complex, but I have not been able to implement any simpler way that actually works.) I'm using a…
DaveC426913
  • 2,012
  • 6
  • 35
  • 63
27
votes
3 answers

When should I use EventEmitter?

I read a lot of things about EventEmitter. But I do not know in which case I need to use it in my Node.js application.
Zagonine
  • 2,213
  • 3
  • 22
  • 29
27
votes
3 answers

How do you share an EventEmitter in node.js?

I want to emit events from one file/module/script and listen to them in another file/module/script. How can I share the emitter variable between them without polluting the global namespace? Thanks!
fancy
  • 48,619
  • 62
  • 153
  • 231
26
votes
2 answers

Angular2, unsubsribe from event in ngOnDestroy

In my application I have some components that communicate by means of EventService. @Injectable() export class EventService { public myEvent: EventEmitter = new EventEmitter(); constructor() {} } This service is injected in a…
TizianoL
  • 1,271
  • 2
  • 11
  • 13
25
votes
2 answers

Use EventEmitter in ES6 class

I am trying to get the EventEmitter in my own class running in ES6: "use strict"; const EventEmitter = require('events'); class Client extends EventEmitter{ constructor(token, client_id, client_secret, redirect_uri, code){ super(); …
Alaska
  • 309
  • 1
  • 4
  • 9
25
votes
4 answers

EventEmitter and Subscriber ES6 Syntax with React Native

I am trying to implement an EventEmitter/Subscriber relationship between two components in a react native class. I have seen referenced the following materials: React Native - Event Emitters by Colin Ramsay React Native - Call Function of child…
Adam Jakiela
  • 2,188
  • 7
  • 30
  • 48
21
votes
2 answers

How do I write non-blocking code in Node.js?

I can write non-blocking I/O in Node.js very easily. It's what the entire library is set up for. But any computation done is blocking. Any message passing over event emitters are blocking. For example, emitting events are resolved immediately and…
Raynos
  • 166,823
  • 56
  • 351
  • 396
21
votes
2 answers

Angular2: mouse event handling (movement relative to current position)

My user should be able to move (or rotate) an object by mouse in a canvas. When mouse events occur the screen coordinates are used to calculate the delta (direction and length) to the last event. Nothing special... mousedown (get the first…
Meiko Rachimow
  • 4,664
  • 2
  • 25
  • 43
20
votes
3 answers

Node.js: how can I return a value from an event listener?

How to i return value from the an event listeners? See example below: const EventEmitter = require("events").EventEmitter; emitter = new EventEmitter(); emitter.on("sayHello", function(message) { return message + " World"; }); let helloMessage =…
Hasan Bayat
  • 926
  • 1
  • 13
  • 24
18
votes
4 answers

QueryList changes subscribe does not work

I have a QueryList in a component. I am adding dynamically other components, that will be present in the QueryList, but if I subscribe to the changes of the QueryList, nothing happens. I thought it is because I subscribed in ngAfterViewInit, but the…
István
  • 5,057
  • 10
  • 38
  • 67
18
votes
1 answer

Angular 2: Call function from a string name

I'm not sure is it question related to Angular 2 or more to Typescript itself. But anyway, I have a component which emits object Here is how I catching the event private gridEvent(event) { …
Majesty
  • 2,097
  • 5
  • 24
  • 55
18
votes
1 answer

Unable to figure out correct EventEmitter or Observable Syntax in Angular2 Services

I'm having a hard time finding much in the way of examples/guides for using observables in an Angular2 service. There is stuff for html templates binding with EventEmitter but that doesn't seem right for a service. One of the big driving themes is…
Dennis Smolek
  • 8,480
  • 7
  • 30
  • 39
18
votes
2 answers

Angular 2 event broadcast

New to Angular 2. I'm working on broadcast a event between same level component. Currently I know EventEmitter just can transfer a event to upper level component. I have checked this this link and know observable may be a way to solve my problem,…
Garry
  • 1,177
  • 3
  • 14
  • 22
17
votes
2 answers

Node.js EventEmitter: How to bind a class context to the event listener and then remove this listener

Is there a way to access to the class context in the event listener method with possibility to remove the listener? Example 1: import {EventEmitter} from "events"; export default class EventsExample1 { private emitter: EventEmitter; …
Dominik Palo
  • 2,873
  • 4
  • 29
  • 52
1
2
3
63 64