Angular Signals or RxJS - They are not a replacement

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 ก.ค. 2023
  • Here we compare Angular Signals vs RxJS to show that you can't replace RxJS with Signals. This is not possible. Learn how to combine Angular Signals with RxJS to get the best results.
    ► CHECK MY COURSES - monsterlessons-academy.com/co...
    MOST POPULAR COURSES
    ► Building real project with Angular + NgRx - monsterlessons-academy.com/co...
    ► Building real NestJS API - monsterlessons-academy.com/co...
    ► Javascript interview questions - monsterlessons-academy.com/co...
    ► Angular Interview Questions monsterlessons-academy.com/co...
    ► Building real fullstack project - monsterlessons-academy.com/co...
    ► Mastering Git - monsterlessons-academy.com/co...
    ► Mastering Docker and Docker Compose - monsterlessons-academy.com/co...
    ► Building real project with React Hooks - monsterlessons-academy.com/co...
    ► Building real project with Vue + Vuex - monsterlessons-academy.com/co...
    FOLLOW ME
    ► TWITTER - / monster_lessons
    ► INSTAGRAM - / monsterlessonsacademy
    ► TIKTOK - / monsterlessonsacademy
    REFERENCES
    ► Source code - github.com/monsterlessonsacad...

ความคิดเห็น • 57

  • @LukeAvedon
    @LukeAvedon ปีที่แล้ว +7

    What is it like to be soooo good at Angular? It must be wonderful.

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  ปีที่แล้ว +2

      Dunno. Nothing special. Just learned stuff through the years.

  • @cloudsss83
    @cloudsss83 ปีที่แล้ว +4

    really nice video. a real world problem. different from that tutorials where you get lost thinking where you could use what you are learning and forget about everything because you can't relate. thanks!

  • @leakyabstraction
    @leakyabstraction 9 หลายเดือนก่อน +3

    Also I find that signals have totally different (more limited) use cases. Signal is essentially a value that incorporates change propagation, and as such it feels quite contrived to use them for streaming. You can use an effect() to implement reactive logic that executes for each new value, but that definitely doesn't seem semantic, plus you're forced to provide a starting value, and if that is null or undefined, then you end up having to declare the type as a union with null or undefined, which is again totally not what you'd want for a regular Subject fashion streaming.

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  9 หลายเดือนก่อน

      Yeap, they are done more like a simple alternative to rxjs

    • @antonionogueras6533
      @antonionogueras6533 5 หลายเดือนก่อน

      Why would you not want to do that for Angular? We do it all the time in React

  • @user-dc2mv2po2s
    @user-dc2mv2po2s 4 หลายเดือนก่อน

    Hi Thank you very much, what about when we need to convere observables to signals and it is a form.valuechanges or a parent form.valueschanges knowing that we cannot use toSignal outside of a constructor and inside the constructor the form may not be initialized yet .

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  4 หลายเดือนก่อน

      firstNameSignal = toSignal(this.profileForm.get('firstName').valueChanges, {initialValue: ''});

  • @dinysanchez
    @dinysanchez ปีที่แล้ว +1

    Love this thanks for the great content, as always!

  • @user-tb4ig7qh9b
    @user-tb4ig7qh9b ปีที่แล้ว

    Async state with rxjs.
    Sync state with signal.
    I do not know what the advantage for convert this observable to signal from my side i think it is unnecessery to do that but could you explain the reason.
    And you show very small example i want to ask how it would be if you want not just that but handle api failing to response with signal it will be a hell and that is why devs love angular and like this things just recently fixed with react-query.

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  ปีที่แล้ว +1

      The reason is that 100 functions from rxjs doesn't exist in signals. As I don't want to write them from scratch there is a possibility to convert.

  • @hamza201183
    @hamza201183 6 หลายเดือนก่อน

    If I have a list of articles (or todos) and I delete one of them (with http delete). How can I trigger an new fetch of the list of articles?
    I still struggle with designing code with http calls and signals :(

    • @hamza201183
      @hamza201183 6 หลายเดือนก่อน

      I can reformulate my question in another way:
      In your todo-list tutorial with signals, how do you incorporate and use http calls?

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  6 หลายเดือนก่อน +1

      It doesn't change anything about API calls.
      deleteArticle(id) {
      this.http.delete(url + id).subscribe(() => {
      const updatedArticles = this.articlesSig().filter(article => article.id !== id)
      this.articlesSig.set(updatedArticles)
      })
      }
      Kind of like this

    • @hamza201183
      @hamza201183 6 หลายเดือนก่อน

      @@MonsterlessonsAcademy Ok thank you very much! Finally your approach is what I ended up doing.
      (I just used sig.update(...) instead of filter(...) then set(...)) but it's the same idea!

  • @ferlezcano
    @ferlezcano ปีที่แล้ว +1

    Great video, as always! 💪
    I just have one Q: There's no need to manually unsubscribe?

    • @PlerbyMcFlerb
      @PlerbyMcFlerb ปีที่แล้ว

      This. It's clear as mud to me how angular cleans up the signal

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  ปีที่แล้ว +2

      This is the best answer. I will probably record Observables vs Signals video for better understanding.

  • @juanpabloguerra9512
    @juanpabloguerra9512 3 หลายเดือนก่อน

    what do you mean with digest cycle? From my understanding, signals prevent change detection across the whole app, instead it's more granular. Is this what you are referring to?
    Also I bought your course on ngrx and angular and it is great!

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  3 หลายเดือนก่อน

      Yes I mean change detection cycle. You've got it right. For some reason I used the term from AngularJS.
      Glad you like my NgRX course!

  • @evok3r
    @evok3r 8 หลายเดือนก่อน

    This is a good example of how mixing signals and RxJS can work out. However, with an additional signal for the articles that is updated inside an async effect based on the search value you can achieve the same goal with just the signals API.

  • @Valdemar268
    @Valdemar268 ปีที่แล้ว

    thanks for the clear explanations

  • @harvey_04
    @harvey_04 ปีที่แล้ว

    Omg what theme is that?looks beautiful

  • @user-px8br7lw5k
    @user-px8br7lw5k 2 หลายเดือนก่อน

    so why use here signals? we can use behaviour subject for same thing

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  2 หลายเดือนก่อน

      I already covered that th-cam.com/video/RLoACfLYwPs/w-d-xo.htmlsi=jx-D8LSEUqTTv79c

  • @pragadeesh2050
    @pragadeesh2050 10 หลายเดือนก่อน

    impressive and real use case explained well

  • @pietrosmusi1409
    @pietrosmusi1409 ปีที่แล้ว

    can you pass signals as props?

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  ปีที่แล้ว

      I didn't try that yet but I don't see why not.

    • @pietrosmusi1409
      @pietrosmusi1409 ปีที่แล้ว

      @@MonsterlessonsAcademy I passed them but they lose reactivity, I tried computed signals based on signal prop and they don't work

  • @davidkpidiba8591
    @davidkpidiba8591 ปีที่แล้ว

    Thanks for the video

  • @MrEvilyogurt
    @MrEvilyogurt 3 หลายเดือนก่อน

    Possible dumb question: why not just use rxjs in this case rather than converting between signals and rxjs obersvabless? Would it not be better to use subject?

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  3 หลายเดือนก่อน +1

      Signal doesn't trigger full tree change detection mechanism but only the current component.

    • @MrEvilyogurt
      @MrEvilyogurt 3 หลายเดือนก่อน

      @@MonsterlessonsAcademy Ohh that makes sense thank you very much for the reply

  • @tranedev
    @tranedev 6 หลายเดือนก่อน

    One of the best content for angular developers🤜🤛

  • @CHAIMASOMRANI
    @CHAIMASOMRANI 2 หลายเดือนก่อน

    Great video

  • @valikonen
    @valikonen ปีที่แล้ว

    Alex, RXJS it's to big to be used just for http requests, Angular must use some native API from JS. RxJS will disappear!

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  ปีที่แล้ว

      Maybe. We'll see.

    • @aravindmuthu5748
      @aravindmuthu5748 ปีที่แล้ว +1

      Rxjs will not disappear. It is too great by itself and doesn't require Angular. Angular should let go of Rx and build native http client requests.

  • @MhmmDonuts
    @MhmmDonuts ปีที่แล้ว

    Personally there is no "OR" i use both =D

  • @FredoCorleone
    @FredoCorleone 10 หลายเดือนก่อน

    Debounce time, distinct until changed and switch map are the reasons rxjs sold so well. For all the rest rxjs is inferior to other options IMO, infact most people do lastValueFrom on http requests, this is a clear demonstration that async/await wins when it comes to http request handling. The command/query paradigm sucks, imperative is much better than declarative, because everybody understands the former, the only thing which goes well with declarative programming is UI (template stuff ngIfs etc).

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  10 หลายเดือนก่อน +1

      Thank you for sharing your opinion!

    • @tarquin161234
      @tarquin161234 หลายเดือนก่อน

      "Imperative is better than declarative". I've used both and declarative is far, far superior for complex components.

  • @Storiada
    @Storiada 3 หลายเดือนก่อน

    Title is totally misleading.

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  3 หลายเดือนก่อน

      Where is it misleading?

    • @Storiada
      @Storiada 3 หลายเดือนก่อน

      @@MonsterlessonsAcademy you haven’t done a comparison of case when rxjs and when observables. Title makes you think that you can see one or the other, while would have been really nice to highlight each one’s advantages.

    • @MonsterlessonsAcademy
      @MonsterlessonsAcademy  3 หลายเดือนก่อน

      @@Storiada Use signals everywhere and use rxjs when you can't solve your problem with signals.

    • @Storiada
      @Storiada 3 หลายเดือนก่อน

      @@MonsterlessonsAcademy not sure about your reply to my comment.
      I was just highlighting that the title suggest a comparison video between then.
      While, the truth is... you are combining them.
      By end it's Rxjs AND Signal, and not Rxjs OR Signals.
      Nevertheless, good example in how to use them together.