本文介绍了Angular 2中的EventEmitter.next()和EventEmitter.emit()之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
EventEmitter.emit()
和EventEmitter.next()
有什么区别?两者都将事件调度到订阅的侦听器.
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});
}
}
EventEmitter的文档目前并不那么有用.
The documenation for the EventEmitter is not so helpful at the moment.
推荐答案
它们执行相同的操作. emit()
是当前版本,next()
已过时.
They do the same. emit()
is the current version, next()
is deprecated.
这篇关于Angular 2中的EventEmitter.next()和EventEmitter.emit()之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!