Handle Click Events with Subjects

InstructorJohn Lindquist

Share this video with your friends

Send Tweet

While Angular usually uses event handlers to manage events and RxJS typically uses Observable.fromEvent, a good practice when using Angular and RxJS combined is to use Subjects and push the value through each event so that you can use it as part of your stream.

Mike thompson
~ 8 years ago

Slight aside here, but I noticed you experienced the same issue I was having with WebStorm auto-importing with double quotes instead of single quotes. Any way to have WebStorm auto-import with single quotes instead of double quotes?

Kevin Pinny
~ 7 years ago

Hello John,

How you handle passing through events between parent and child. For example: Child has a subject.next() in it's template and has to pass data back up to it's parent component.

How would the parent component get this event using RxJs. Exactly the same way with subject.next() in the template of the parent component? The data should then get manipulated by the parent en pushed down again in the child component. So child component (dumb components) should only have event emitters with subject.next, but not switchMap logic and stuff?

Mark Kramer
~ 6 years ago

About time to update these to use pipeable operators instead of the old patched prototype operators. At least make a note that this was done with version 4 or so.