What is the difference between EventEmitter.emit() and EventEmitter.next()? Both dispatching the event to the subscribed listeners.
export class MyService {
@Output() someEvent$: EventEmitter<any> = new EventEmitter();
someFunc() {
this.someEvent$.emit({myObj: true});
this.someEvent$.next({myObj: true});
}
}
The documenation for the EventEmitter is not so helpful at the moment.
They do the same. emit() is the current version, next() is deprecated.
来源:https://stackoverflow.com/questions/35840576/difference-between-eventemitter-next-and-eventemitter-emit-in-angular-2