No video

Promises vs Observables - What Is the Difference?

  Рет қаралды 7,403

Monsterlessons Academy

Monsterlessons Academy

Күн бұрын

Пікірлер: 31
@kingsleyetoka2792
@kingsleyetoka2792 Жыл бұрын
An actual interview question. Many thanks for sharing
@MonsterlessonsAcademy
@MonsterlessonsAcademy Жыл бұрын
Glad you enjoyed it!
@nnikchikvaidze
@nnikchikvaidze Жыл бұрын
Greetings from country of Georgia, well done! always watching your videos, thank you for good content ! 😊
@MonsterlessonsAcademy
@MonsterlessonsAcademy Жыл бұрын
Thanks for watching!
@StasSorochan
@StasSorochan Жыл бұрын
In my stege period they put me in project on Angular. I started to learn it from zero because i have studied React before. Your video helps me understand some things. Thank you. Also i saw what you use vim, so i decided to touch nvim and then it's away we go, nvchad, plugins, lsp and it's been like that for a month now.
@MonsterlessonsAcademy
@MonsterlessonsAcademy Жыл бұрын
That's great!
@val-do
@val-do Жыл бұрын
Greetings from Georgia 🇬🇪
@MonsterlessonsAcademy
@MonsterlessonsAcademy Жыл бұрын
Hi from Germany
@Z3rgatul
@Z3rgatul Жыл бұрын
Thanks, this is really confusing for new ppl in angular like me. Now I see advantages for stateless pages, need to learn it more to see advantages for stateful pages.
@MonsterlessonsAcademy
@MonsterlessonsAcademy Жыл бұрын
Glad it was helpful!
@Vaivis
@Vaivis 2 ай бұрын
Thank you
@MonsterlessonsAcademy
@MonsterlessonsAcademy 2 ай бұрын
You're welcome
@Georgii1212
@Georgii1212 Жыл бұрын
Hello! Thanks a lot for the tutorial! Can you please give a bit more details about the last difference you mention : errors. I thought that there was a catch block for errors, in promises ...?
@MonsterlessonsAcademy
@MonsterlessonsAcademy Жыл бұрын
It's not really a difference. You get errors in catch for promise and you pack either catchError function in observable or you handle an error inside subscription
@tobalhenriquez8233
@tobalhenriquez8233 11 ай бұрын
You are the best.
@MonsterlessonsAcademy
@MonsterlessonsAcademy 11 ай бұрын
Thanks!
@jluisOlivares
@jluisOlivares Жыл бұрын
Hi, would you please make a video about the new angular signals sharing data between components? Thanks in advance.
@MonsterlessonsAcademy
@MonsterlessonsAcademy Жыл бұрын
Hi, thank you for the idea. I have a plan for such video.
@chrisb3902
@chrisb3902 Жыл бұрын
Great explanation and video!
@MonsterlessonsAcademy
@MonsterlessonsAcademy Жыл бұрын
Glad you liked it!
@aleksandr95
@aleksandr95 Жыл бұрын
Thx for helpful video 😊
@MonsterlessonsAcademy
@MonsterlessonsAcademy Жыл бұрын
My pleasure 😊
@naylagomes1212
@naylagomes1212 Жыл бұрын
aren't promises better for cases where one action needs to wait for another to finish? for example, I have method A and B, method A needs to wait for the request inside method B to finish I particularly don't like using subscribe on occasions like this, as it makes me put method A inside method B's subscribe so I can wait for it to finish, and sometimes that's not my goal
@MonsterlessonsAcademy
@MonsterlessonsAcademy Жыл бұрын
No. I don't see any cases where promises are better than rxjs except of the reason that they are available without libs and by using fetch you get promises. In RxJS you have concat map where second observable waits for first observable. result$ = foo$.concatMap(fooRes => getBarData(fooRes)) No subscribes needed
@Z3rgatul
@Z3rgatul Жыл бұрын
Sorry, I started refactoring promises into observables and quickly realized how wacky my code becomes. Just basic example, http request, get response, if one of parameters equals to something, i need to get another http request, get response, and do some filtering with first response. example async loadData(param1, param2) { let data1 = await service.getData1(param1, param2); if (!param2) { let data2 = await service.getData2(); data1 = data1.filter(....something with data2....); } return data1; } I am feeling like I am writing state machine in observables instead of compiler doing the same for me with promises/await/async. All these simple examples from courses work fine, but with something more difficult I feel like observables suck
@MonsterlessonsAcademy
@MonsterlessonsAcademy Жыл бұрын
Well you need to learn rxjs a bit more. Unfortunately I don't help with the code in the comments because it takes a lot of time. Check some of my videos on rxjs kzfaq.info/get/bejne/aLpjeZiFy9i9p30.html kzfaq.info/get/bejne/aOB6hdpkqNLDhqc.html kzfaq.info/get/bejne/iqyIo9KSx92mlok.html
@mehdi-vl5nn
@mehdi-vl5nn Жыл бұрын
Observable = Observer pattern + iterator pattern
@MonsterlessonsAcademy
@MonsterlessonsAcademy Жыл бұрын
Yeap!
@thmscq5713
@thmscq5713 Жыл бұрын
but using observables kinda wastes the big potential of await, doesn't it? if we want a synchronous function we have to transform it into a promise each time
@MonsterlessonsAcademy
@MonsterlessonsAcademy Жыл бұрын
I think you understand it wrong. Await doesn't make your function sync. It just looks sync and every next line with await waits for previous line to be done. But it is still 100% async. Regarding your question async await is just sugar for promises. You don't get anything new and it has all the same problems.
@fauzi5848
@fauzi5848 4 ай бұрын
1:05 what did you say?
Behaviorsubject vs Subject rxjs - What to Use?
7:02
Monsterlessons Academy
Рет қаралды 8 М.
Change Detection in Angular - You Project Is 20x Slower!
15:16
Monsterlessons Academy
Рет қаралды 70 М.
这三姐弟太会藏了!#小丑#天使#路飞#家庭#搞笑
00:24
家庭搞笑日记
Рет қаралды 52 МЛН
Look at two different videos 😁 @karina-kola
00:11
Andrey Grechka
Рет қаралды 15 МЛН
Parenting hacks and gadgets against mosquitoes 🦟👶
00:21
Let's GLOW!
Рет қаралды 13 МЛН
The Biggest Misconception of PROMISES vs OBSERVABLES
5:07
Joshua Morony
Рет қаралды 13 М.
Why Angular Signals? Write Your First Signal
14:25
Angular University
Рет қаралды 10 М.
Typescript Type vs Interface - Which One Is Better?
8:26
Monsterlessons Academy
Рет қаралды 6 М.
Angular Interview Questions You Should Know
10:01
Monsterlessons Academy
Рет қаралды 56 М.
Angular 17 Features With Examples - You Must Know That
14:44
Monsterlessons Academy
Рет қаралды 38 М.
RxJs Теория: Observable, Observer, Subscription, Pipe
15:38
Максим Гром
Рет қаралды 39 М.
How are Observables Different from Promises? | Beginner RXJS Lessons
8:46