Angular 2 Event emitters vs Subject

前端 未结 3 2009
Happy的楠姐
Happy的楠姐 2020-12-04 20:46

In Angular 2 what is the difference between Event Emitter and Subject for announcing an event? It seems like event emitters are less complicated to declare....Which way is p

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-04 21:41

    Also EventEmitter gets cleaned up automatically unlike custom Subjects that you need to unsubscribe to in the onDestroy lifecycle hook.

提交回复
热议问题