Angular 2中的EventEmitter.next()和EventEmitter.emit()之间的区别


Answers:



2

在最新版本(Ng9)中,的源代码event_emitter.ts如下:

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从父类扩展Subject。和您可能期望的emit方法调用super.next()

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.