Best practices for passing data between components in Angular - 3 Angular Tips

preview_player
Показать описание
More Angular tips and tricks in this video. Angular is a beast of a framework with an overwhelming amount of possibilities. For example, what is the best way to pass data between components in Angular? That is the question I address in this video. Along with it, I give two more tips to help improve the quality of your Angular code, your utility of TypeScript and your understanding of RXJS.

I feel like I went through several stages as I learned Angular.
Stage 1: Following tutorials and trying to find meaning.
Stage 2: Exploring and expanding upon tutorials.
Stage 3: Getting into the documentation, discovering advanced topics and becoming more consistent, organized, and efficient.

This video is for learners late in stage 2 or early into stage 3. It assumes familiarity with the following topics in RXJS:

How are Observables Different from Promises? | Beginner RXJS Lessons

RXJS Operators Explained with Examples: Switchmap, Map, + More

CONTENTS
Literal Types and Literal Narrowing: 0:34
ReplaySubject and how it differs from other RxJS Subjects: 2:41
The best way to pass data between components in Angular: 6:11

My name is Ben and I am a software developer. I have iOS apps and a few web apps. (Every other web app is comparatively small and was developed using vanilla JavaScript.) If you'd like to see what I'm about or what I've done, check out the links below:

THE PERFECT BOARDGAME - A site for matching tabletop games with your unique preferences

SOLUTIONS FOR X - My first published iOS apps

NEVER BEN BETTER - My Blog

MY PATREON SITE:

MY GEAR
Sony ZV 1

Fifine Condenser Recording Microphone
Рекомендации по теме
Комментарии
Автор

You have what comes across as a very natural ability, and great analogies, for explaining these very useful, but often confusing, technical topics. I've found myself coming back to your videos repeatedly (share-replay). I know 'I'd appreciate some minimal, but end-to-end, code examples to refer to (e.g. a service to store (and share) selected state across components: etc), but appreciate the time required to produce something like that. Clearly you are the perfect person to be building an LMS! - A natural teacher.

rickwhitehead
Автор

Great tutorial. You have a knack of explaining difficult concepts

abhisheksitar
Автор

Veeerryyy interesting about the replay subject approach - I'm gonna give it try - thanks man 👍
Update : It worked! Big thanks NBB

nerdiloo
Автор

It’s difficult to find clear concise tutorials that illustrate the strength of the Angular platform. Yours is one of the few ones to do so in 11 mins.

rembautimes
Автор

Nice, thanks. If you share a repo with the code for each video that would be great to take a closer look.

hernanvelazquez
Автор

thx man, plz create more angular tutorials

mahdiandalib
Автор

I like literally everything u do .. And what microphone and camera name u use ..

kjmoses
Автор

Hello @NeverBenBetter,
Do you teach full online video course to Angular?
If YES, it would be great.
If NO, can you pls make some depth video online!?

blexyt
Автор

10:19 where do these functions get called from? When do they get called? this.doOnChange() and this.whenSynched()

Almighty_Flat_Earth
Автор

Just wondering if we use ReplaySubject with a type of Book[] as the generics, does it automatically add null or undefined to it?
Regardless whether it does or not, I don't think Replay is a lot better than Behavior subject. Because it forces the users to be aware of the type. If it can never be null then instantiate with empty array. If we instantiate with null then we have to include null.
For for ReplaySubject, we don't know.
If it always add null to the type then we always have to handle that throughout our code base.
If it does not atuo add null to the type then we are likely to get our favorite null pointer.
So base on what is discribed in the vid, I don't think we should use ReplaySubject. If possible, stick to BehaviorSubject, yes we might need to instantiate with null but so what, the benefit is a much safer application.

hanmingzheng
Автор

Would be good if you can just call it union type since that's the official term

hanmingzheng
Автор

Let us think about another option than var.

code-coaching
Автор

I like literally everything u do .. And what microphone and camera name u use ..

kjmoses