Difference between EventEmitter.next() and EventEmitter.emit() in Angular 2
They do the same. emit()
is the current version, next()
is deprecated.
In the latest version(Ng9), the source code of event_emitter.ts
goes as following:
export class EventEmitter<T extends any> extends Subject<T> { /** * Emits an event containing a given value. * @param value The value to emit. */ emit(value?: T) { super.next(value); }}
EventEmitter
extends from parent class Subject
. And emit
method call super.next()
as you may expected.