Use takeUntilDestroyed to Unsubscribe from Angular's Observables

  Рет қаралды 4,730

Deborah Kurata

Deborah Kurata

Күн бұрын

Пікірлер: 26
@metric152
@metric152 3 ай бұрын
Always killing the game. Thanks for another great video.
@deborah_kurata
@deborah_kurata 3 ай бұрын
Thank you so much!
@ariensharma9859
@ariensharma9859 12 күн бұрын
This content is truly remarkable! It is hard to believe that someone can explain such complex concepts with such ease.
@etexalbania7301
@etexalbania7301 3 ай бұрын
Thank you Deborah. When you have time please do a video for 2 dependent dropdowns using rxjs, like country for the first and capitals the second dropdown. All the best
@deborah_kurata
@deborah_kurata 3 ай бұрын
Thank you! Great suggestion! I'll add it to my list.
@Wadih-bc
@Wadih-bc 9 күн бұрын
You're awesome! Thanks a lot :)
@CarlesNavedaPallares
@CarlesNavedaPallares 3 ай бұрын
Thank you for creating and sharing such amazing content! Your clear and easy-to-understand explanations, even for complex concepts, are incredibly valuable and helpful. Keep up the fantastic work! 😊
@deborah_kurata
@deborah_kurata 3 ай бұрын
Wow! Thank you so much! 😊
@andsons159
@andsons159 3 ай бұрын
Proud to watch this as the first person, I have a question how should one handle a case of "update list of users when backend updates them" must one use something like firebase fcm or can RxJs come to the rescue?
@deborah_kurata
@deborah_kurata 3 ай бұрын
😊 RxJS out of the box doesn't have features to support real-time messaging. SignalR, which uses WebSocket, is an option that returns an observable. Or you can use WebSocket directly. It looks like FCM may also support this scenario. I've not ever had this requirement in the applications I've built, so I don't have any experience with any of these options.
@babutschi
@babutschi 3 ай бұрын
Very helpful! Thanks.
@deborah_kurata
@deborah_kurata 3 ай бұрын
Great to hear! 😊
@CodingAbroad
@CodingAbroad 3 ай бұрын
So I guess we can replace the normal takeUntil with takeUntilDestroyed?
@deborah_kurata
@deborah_kurata 3 ай бұрын
Yep.
@CodingAbroad
@CodingAbroad 3 ай бұрын
@@deborah_kurata thank you :) maybe a broad question but couldn’t we just use this for every single observable we need to subscribe to manually from now on? Or are there occasions where using takeUntilDestroyed is not ideal?
@deborah_kurata
@deborah_kurata 3 ай бұрын
@@CodingAbroad In my coding, I try to use toSignal whenever I can. Then the takeUntilDestroyed isn't needed. But if I can't use toSignal and have to manually subscribe, then I go with takeUntilDestroyed.
@CodingAbroad
@CodingAbroad 3 ай бұрын
@@deborah_kurata ah just seen your recent toSignal video to understand it better - thanks very helpful. Is it best practise to leave observables that are started using the template async pipe like this? advertisers$ = this.httpService.getCombinedData(); @if ((advertisers$ | async); as searchData) { } Or is there some signals magic I should be doing here too? I just want to list data out read only in this circumstance
@deborah_kurata
@deborah_kurata 3 ай бұрын
What you have still works. And at least as of now, there are no plans to deprecate the async pipe. But the Angular team is pushing forward with signals as the primary mechanism for displaying data from a component. At some future point, you could modify that observable (advertisers$) to a signal using `toSignal()`. Then display the signal in the template without the async pipe. advertisers = toSignal(this.httpService.getCombinedData()); @if (advertisers; as searchData) { } And you may not need the `as` clause, but it is still supported with signals.
@graydhd8688
@graydhd8688 25 күн бұрын
Missed an opportunity to add "Unless it's my channel" to rule 1
@deborah_kurata
@deborah_kurata 24 күн бұрын
😄
@richarddefortune1329
@richarddefortune1329 3 ай бұрын
Great video as usually.
@deborah_kurata
@deborah_kurata 3 ай бұрын
Thanks!
@rkrao8582
@rkrao8582 3 ай бұрын
Hey Deborah, great content always. I have question here ! So what happens with CatchError returning EMPTY? Should I put takeUntilDestroyed before or after? I guess I didn't totally understand how teardown logic works.
@deborah_kurata
@deborah_kurata 3 ай бұрын
Thank you! Yes, you could modify the setError method to return EMPTY. You'd then want to change the code a bit because if there isn't a set of todos returned (even an empty set of todos), the current code implementation won't turn off the loading flag. I guess that provides an example of how being lazy (and not separately setting the loading flag off), can cause issues down the road. 😊 Regarding if it should be before or after takeUntilDestroyed ... in our example we use a switchMap and add the catchError in it's pipeline. That is the recommended approach.
@Erril_Ferndal
@Erril_Ferndal 3 ай бұрын
perfect, thats what i need! :)
@deborah_kurata
@deborah_kurata 3 ай бұрын
Great!
Build Generalized DRY Angular Code with Generics
14:44
Deborah Kurata
Рет қаралды 10 М.
Zoneless Angular Applications in V18
14:00
Deborah Kurata
Рет қаралды 17 М.
From Small To Giant Pop Corn #katebrush #funny #shorts
00:17
Kate Brush
Рет қаралды 72 МЛН
Стойкость Фёдора поразила всех!
00:58
МИНУС БАЛЛ
Рет қаралды 5 МЛН
когда не обедаешь в школе // EVA mash
00:51
EVA mash
Рет қаралды 3,9 МЛН
I only ever use *these* RxJS operators to code reactively
25:25
Joshua Morony
Рет қаралды 130 М.
Pitfalls Of Using takeUntil and takeUntilDestroyed RxJS Operators
10:04
Decoded Frontend
Рет қаралды 21 М.
Error Handling with Observables
10:19
Deborah Kurata
Рет қаралды 7 М.
Angular's New Signal Inputs
10:48
Deborah Kurata
Рет қаралды 8 М.
Deferrable Views in Angular 17
10:01
Web Tech Talk
Рет қаралды 1,5 М.
Currying for More Generalized Angular Code
12:41
Deborah Kurata
Рет қаралды 4,8 М.
Why didn't the Angular team just use RxJS instead of Signals?
8:15
Joshua Morony
Рет қаралды 96 М.
Dynamic Component in Angular (2024)
17:48
Decoded Frontend
Рет қаралды 19 М.
3x 2x 1x 0.5x 0.3x... #iphone
0:10
Aksel Alze
Рет қаралды 2,7 МЛН
Cómo pensaba que sería el iPhone 16 😭
0:12
Alan
Рет қаралды 1,9 МЛН
Китайцы сделали телефон БАЯН
0:14
Собиратель новостей
Рет қаралды 1,6 МЛН
Google Pixel 8 Pro на 128 gb! Илии.... #shorts #shortvideo
0:20
UNIT | ЮНИТ | IPHONE 15
Рет қаралды 1,6 МЛН
The BRIGHTEST Phone Flash In The World
0:46
Mrwhosetheboss
Рет қаралды 34 МЛН
Самые крутые школьные гаджеты
0:46
veloloh
Рет қаралды 1 МЛН