加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

在角度2中EventEmitter.next()和EventEmitter.emit()之间的区别

发布时间:2020-12-17 08:19:00 所属栏目:安全 来源:网络整理
导读:EventEmitter.emit()和EventEmitter.next()有什么区别?都将事件发送给订阅的听众。 export class MyService { @Output() someEvent$: EventEmitterany = new EventEmitter(); someFunc() { this.someEvent$.emit({myObj: true}); this.someEvent$.next({myO
EventEmitter.emit()和EventEmitter.next()有什么区别?都将事件发送给订阅的听众。
export class MyService {
  @Output() someEvent$: EventEmitter<any> = new EventEmitter();

  someFunc() {
   this.someEvent$.emit({myObj: true});

   this.someEvent$.next({myObj: true});
  }
}

documenation for the EventEmitter目前不是很有帮助。

他们做同样的事情emit()是当前版本,next()已被弃用。

参见https://github.com/angular/angular/blob/b5b6ece65a96f5b8f134ad4899b56bf84afe3ba0/modules/angular2/src/facade/async.dart#L49

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读