139. An Important Note about Route Observables
Jul 15, 2026 05:34
· 2:42
· English
· Whisper Turbo
· 2 Speakers
Această transcriere expiră astăzi.
Actualizarea pentru stocarea permanentă →
Se afișează doar
0:02
S…
Speaker 2 (139. An Important Note about Route Observables)
In the last lecture,
0:03
S…
Speaker 2 (139. An Important Note about Route Observables)
we learned how we can subscribe to our params to update them
0:07
S…
Speaker 2 (139. An Important Note about Route Observables)
or to react to any changes to them and update our page if we already
0:11
S…
Speaker 2 (139. An Important Note about Route Observables)
are on that page.
0:12
S…
Speaker 2 (139. An Important Note about Route Observables)
And we set up this subscription using observables and this works
0:17
S…
Speaker 2 (139. An Important Note about Route Observables)
fine and you don't have to change anything here.
0:19
S…
Speaker 2 (139. An Important Note about Route Observables)
I want to bring something to your attention though.
0:22
S…
Speaker 2 (139. An Important Note about Route Observables)
The fact that you don't have to add anything else to this
0:26
S…
Speaker 2 (139. An Important Note about Route Observables)
component here simply is because Angular
0:29
S…
Speaker 2 (139. An Important Note about Route Observables)
does something for you in the background which is super
0:33
S…
Speaker 2 (139. An Important Note about Route Observables)
important.
0:34
S…
Speaker 2 (139. An Important Note about Route Observables)
It cleans up the subscription you set up here whenever
0:38
S…
Speaker 2 (139. An Important Note about Route Observables)
this component is destroyed.
0:39
S…
Speaker 2 (139. An Important Note about Route Observables)
Because if it wouldn't do this,
0:42
S…
Speaker 2 (139. An Important Note about Route Observables)
what are you doing here?
0:43
S…
Speaker 2 (139. An Important Note about Route Observables)
You're subscribing to parameter changes and let's say you then leave this
0:47
S…
Speaker 2 (139. An Important Note about Route Observables)
component and later you come back.
0:49
S…
Speaker 2 (139. An Important Note about Route Observables)
Well, once you left,
0:50
S…
Speaker 2 (139. An Important Note about Route Observables)
this component will be destroyed,
0:52
S…
Speaker 2 (139. An Important Note about Route Observables)
and when you come back,
0:53
S…
Speaker 2 (139. An Important Note about Route Observables)
a new one will be created.
0:54
S…
Speaker 2 (139. An Important Note about Route Observables)
But this subscription here will always live on in memory
0:58
S…
Speaker 2 (139. An Important Note about Route Observables)
because it's not closely tied to your component.
1:01
S…
Speaker 2 (139. An Important Note about Route Observables)
So if the component is destroyed,
1:03
S…
Speaker 2 (139. An Important Note about Route Observables)
the subscription won't.
1:04
S…
Speaker 1 (139. An Important Note about Route Observables)
Now,
1:05
S…
Speaker 2 (139. An Important Note about Route Observables)
it will be here because Angular handles this destroying of
1:09
S…
Speaker 2 (139. An Important Note about Route Observables)
the subscription for you.
1:10
S…
Speaker 2 (139. An Important Note about Route Observables)
But theoretically,
1:12
S…
Speaker 2 (139. An Important Note about Route Observables)
you might want to implement the onDestroy lifecycle hook,
1:16
S…
Speaker 2 (139. An Important Note about Route Observables)
importing it from atAngularCore,
1:19
S…
Speaker 1 (139. An Important Note about Route Observables)
Therefore,
1:20
S…
Speaker 2 (139. An Important Note about Route Observables)
you have to implement ng on destroy.
1:22
S…
Speaker 2 (139. An Important Note about Route Observables)
And then you could store this subscription here in some
1:26
S…
Speaker 1 (139. An Important Note about Route Observables)
property.
1:27
S…
Speaker 2 (139. An Important Note about Route Observables)
Let's name it params subscription,
1:30
S…
Speaker 2 (139. An Important Note about Route Observables)
which will be of type subscription.
1:33
S…
Speaker 2 (139. An Important Note about Route Observables)
And subscription needs to be imported from rxjs
1:38
S…
Speaker 2 (139. An Important Note about Route Observables)
subscription.
1:39
S…
Speaker 2 (139. An Important Note about Route Observables)
rxjs is the package offering all this observables
1:43
S…
Speaker 2 (139. An Important Note about Route Observables)
functionality.
1:43
S…
Speaker 2 (139. An Important Note about Route Observables)
As I mentioned,
1:44
S…
Speaker 2 (139. An Important Note about Route Observables)
it's not shipping with Angular,
1:46
S…
Speaker 2 (139. An Important Note about Route Observables)
but Angular is using this package.
1:49
S…
Speaker 2 (139. An Important Note about Route Observables)
So this type here,
1:50
S…
Speaker 2 (139. An Important Note about Route Observables)
this subscription,
1:51
S…
Speaker 2 (139. An Important Note about Route Observables)
this paramSubscription property is now bound to this
1:55
S…
Speaker 2 (139. An Important Note about Route Observables)
subscription we're setting up here when calling subscribe.
1:58
S…
Speaker 2 (139. An Important Note about Route Observables)
This returns us this subscription.
2:00
S…
Speaker 2 (139. An Important Note about Route Observables)
And once the component gets destroyed,
2:03
S…
Speaker 2 (139. An Important Note about Route Observables)
we could now access the subscription and unsubscribe.
2:07
S…
Speaker 1 (139. An Important Note about Route Observables)
And again,
2:08
S…
Speaker 2 (139. An Important Note about Route Observables)
because it's important,
2:08
S…
Speaker 2 (139. An Important Note about Route Observables)
you don't have to do this.
2:10
S…
Speaker 2 (139. An Important Note about Route Observables)
You can leave it as it was before because Angular will do this for
2:14
S…
Speaker 2 (139. An Important Note about Route Observables)
you regarding these route observables.
2:16
S…
Speaker 2 (139. An Important Note about Route Observables)
But if you add your own observables,
2:19
S…
Speaker 2 (139. An Important Note about Route Observables)
and I will come back to this in the observables section following this section.
2:23
S…
Speaker 2 (139. An Important Note about Route Observables)
You have to unsubscribe on your own.
2:25
S…
Speaker 2 (139. An Important Note about Route Observables)
And I just wanted to bring it to your attention because it's always super important to
2:29
S…
Speaker 2 (139. An Important Note about Route Observables)
understand what's happening behind the scenes.
2:31
S…
Speaker 2 (139. An Important Note about Route Observables)
Again, it's not necessary here,
2:33
S…
Speaker 2 (139. An Important Note about Route Observables)
but it doesn't hurt to also do it manually too here.
2:36
S…
Speaker 2 (139. An Important Note about Route Observables)
It won't add anything bad to your app by doing it like this.
Această transcriere a fost generată de AI (reconociune automată de vorbire). Poate conține erori — verificați împotriva audio-ului original pentru utilizare critică. Politica de asociere a aerului intern
Rezumatul
Faceți clic pe Summarize pentru a genera un rezumat al IA a acestei transcripții.
Resumând...
Întreabă Al despre acest text
Întreabă orice despre această transcriere — IA va găsi secțiuni relevante și răspunsul.