jumrifm jumrifm - 2 years ago 397
Javascript Question

Angular 2 EventEmitter performance

I'm working on web-app based on Angular 2. In Angular 1 we had two-way data-bindings, so services could be easily connected with page data using $scope (if we change something in service, data will be automatically updated).

In Angular 2 we have EventEmitter, I thought it's like Angular 1's $scope.$broadcast, so there could be performance issues with this.

What about performance of EventEmitters? Do they slow down application?

Answer Source

Events emitted by EventEmitter don't bubble and also don't broadcast. EventEmitters are for binding from child to parent only.

For broadcasting use shared services.

See also
- https://angular.io/docs/ts/latest/cookbook/component-communication.html#!#bidirectional-service
- updating variable changes in components from a service with angular2
- Delegation: EventEmitter or Observable in Angular2

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download