This new Angular primitive might actually be a viable alternative to RxJS

Поделиться
HTML-код
  • Опубликовано: 25 дек 2024

Комментарии • 61

  • @JoshuaMorony
    @JoshuaMorony  2 месяца назад

    I have a weekly newsletter if you'd like to join: mobirony.ck.page/4a331b9076

  • @aravindmuthu5748
    @aravindmuthu5748 2 месяца назад +25

    This one makes sense. For a truly "All in one" framework like Angular, it is weird that it heavily relied on a totally 3rd party library rxjs for the most basic api requests

    • @SamiullahKhan
      @SamiullahKhan 2 месяца назад +4

      We can't just let go of rxjs after using it for years in http 😅

    • @TayambaMwanza
      @TayambaMwanza 2 месяца назад

      @@SamiullahKhan We're not letting it go, it's just another level up in Angular learning tree.

    • @aheendwhz1
      @aheendwhz1 Месяц назад

      I think it's great if use cases are decoupled and independent - you can use rxJS without Angular or with Angular. This increases resources put into the development, and the use cases tested. It also might improve the popularity, as you can check out rxJS without replacing your frontend framework, and makes the skillset of knowing rxJS more valuable, as it can be used with Angular apps, but also with any other apps, too.
      resource() etc. might be handy if you just want to make an app in Angular and don't need rxJS. But knowlege of resource() etc. won't help you much outside Angular. And it might increase the learning curve for non-Angular developers, who might already know rxJS.

    • @xucongzhan9151
      @xucongzhan9151 Месяц назад +1

      @@aheendwhz1 rxjs is already very popular in the infra layer of frontend libraries. Its download number has surpassed React and Angular combined...

  • @KrisKamweru
    @KrisKamweru 2 месяца назад +3

    This is pretty cool! Excited to see what the final version of v19 will bring

    • @LarsRyeJeppesen
      @LarsRyeJeppesen 2 месяца назад +1

      For me the most important is standalone components as default. I hate having that line in every single entity. I am running v19.next10, v11 should come out today.

    • @LarsRyeJeppesen
      @LarsRyeJeppesen 2 месяца назад

      Annn it's out... amazing.. resource api is now in

  • @lorenzmuller5083
    @lorenzmuller5083 2 месяца назад +3

    That looks great.
    Are there any news on the interplay of signals and reactive Forms though? As long as people have to use valueChanges which is an Observable, rxjs will still stick around

    • @JoshuaMorony
      @JoshuaMorony  2 месяца назад +1

      Nothing announced yet but at this point it is almost guaranteed that we will see something on the forms/signals front at some point

  • @stephenjames2951
    @stephenjames2951 Месяц назад

    All a good description.

  • @3rguy1
    @3rguy1 2 месяца назад +3

    This feature looks similar to Tanstack Query. Nevertheless, a great addition to Angular!

  • @tovawr
    @tovawr Месяц назад

    it's really funny that I created a "StatusAndValue" class in my apps that basically does the same as the "resource" primitive. just make the HTTP request's state (fetching, error, finished) reactive too

  • @alexsandroagustini714
    @alexsandroagustini714 2 месяца назад +15

    It looks pretty nice, but at the same it feels kinda cursed to use "fetch" in Angular

    • @tolstoievski4926
      @tolstoievski4926 2 месяца назад +1

      Why ?

    • @alexsandroagustini714
      @alexsandroagustini714 2 месяца назад

      @@tolstoievski4926 Because Angular has had the HttpClient as a pattern to make http requests since ever (I mean, idk about AngularJS at least, but since then)

    • @alexsandroagustini714
      @alexsandroagustini714 2 месяца назад +1

      Besides, HttpClient has some features on top of fetch, like adding context to interceptors, but this api is in developer preview, so they might change some things before actually releasing it to the public

    • @RodrigoSalesSilva
      @RodrigoSalesSilva 2 месяца назад

      @@alexsandroagustini714 yep, but I think the angular team will make this resource pass through interceptors as well

    • @alexsandroagustini714
      @alexsandroagustini714 2 месяца назад

      @@RodrigoSalesSilva Yeah, if that' the case then it'll be alright

  • @endlacer
    @endlacer 2 месяца назад +1

    is the fetchapi intercepted with the Http_Intercepter like the normal httpClient is?

    • @Shrek_The_Mathematician
      @Shrek_The_Mathematician 2 месяца назад +1

      idk but if you watched till the end you'd see you can use the httpClient inside of the ressource() instead of fetch() at 2:46

  • @cocoscacao6102
    @cocoscacao6102 2 месяца назад +1

    I'd love a motion canvas video on how to do those circles and code...

    • @JoshuaMorony
      @JoshuaMorony  2 месяца назад

      It would probably be fun to do a video on but I don't think it would be of interest to most people who watch the channel, in any case I'm not doing anything super out of the ordinary. There's some examples in the motion canvas repo I think which are great as references for your own animations.

  • @mmorgan4x
    @mmorgan4x 2 месяца назад

    do you think the key name 'request' makes sense for dependencies?

  • @IgorPak-b5n
    @IgorPak-b5n Месяц назад +1

    Signals have drawbacks, we still would need RxJS for event like streams, because signals, because of their structure can pass butches of data which will not happen if you use RxJS
    Signals great for state, RxJS still best for event handling

  • @LarsRyeJeppesen
    @LarsRyeJeppesen 2 месяца назад

    Running V19-Next11 here - it's simply amazing. My favorite is I don't have to use "allowSignalWrites" in effects any longer. phewwwwww it was an eye sore

  • @LarsRyeJeppesen
    @LarsRyeJeppesen 2 месяца назад

    Resource API is now available in V19-Next 11

  • @kylerjohnson988
    @kylerjohnson988 2 месяца назад

    This is a game changer

  • @AK-vx4dy
    @AK-vx4dy 2 месяца назад +43

    Why everybody wanting to remove rxjs, it is beautiful

    • @tbtv9051
      @tbtv9051 2 месяца назад +6

      Because none of them understands it… imo it’s hard to get into it but it’s worth it..

    • @Floubadour
      @Floubadour 2 месяца назад +2

      Beautiful and terrible at the same time.

    • @AK-vx4dy
      @AK-vx4dy 2 месяца назад +4

      @@Floubadour Why terrible?

    • @xdzzz0
      @xdzzz0 2 месяца назад +3

      ​@@AK-vx4dy its hard to write tests, it can be buggy if you don't know what you're doing, lot of edge-case gotchas with null-streams, race conditions, effects compounding when you don't want them, etc.

    • @Raynhardx
      @Raynhardx 2 месяца назад +3

      rxjs is like an ice bath. A bit masochistic but pretty amazing long term. But everyone you try to convince about it is annoyed and disgusted.

  • @van_tigranyan
    @van_tigranyan 2 месяца назад

    So this is react-query for Angular?

  • @bongbui
    @bongbui 2 месяца назад

    we need debounce time for signal

  • @samuelalejandro2104
    @samuelalejandro2104 Месяц назад

    I liked the idea of having an all-in-one primitive to manage basic state use cases, but i did not like the fetch API use. Mainly because to achieve request cancelation we have always to pass this abortSignal, which limits the separation of the requests in a requests service. The rxResource is so much cleaner to make that.
    Furthermore, how can we use interceptors in a fetch-based request? Will it be handled the same way as HttpClient?
    If we want to make RXJS optional i don't think that using the fetch API is the correct way to do that. Maybe we should have a signal-based HttpClient which handles the request cancelation and interceptors

  • @bartheus6709
    @bartheus6709 Месяц назад

    I have feeling that it is like back to the Past ,using Fetch and Promise ?>

  • @SamiullahKhan
    @SamiullahKhan 2 месяца назад +2

    This api guarantees angular is moving away from rxjs, even the helpers like toSignal, toObservable are imported from interop package which means a compat layer not from core

  • @craigritchie8470
    @craigritchie8470 Месяц назад

    The whole Angular without RxJS is confusing to me when the HttpClient service is based on Observables.

    • @aaronhauth8880
      @aaronhauth8880 8 дней назад

      surely that's next on the docket, right?
      if angular is planning to make rxjs optional, then they *must* make their http client service also work with signals.

  • @mfpears
    @mfpears 2 месяца назад

    If it fetches eagerly and doesn't refresh automatically, it's not declarative, because those behaviors will have to be created imperatively.

    • @JoshuaMorony
      @JoshuaMorony  2 месяца назад +2

      I haven't actually used it yet (this is just from a read of the PR, I think it's going to be available in @next this week), so take with a grain of salt. I don't know if its eager or not, but it seems reasonable that it would/could be triggered lazily on signal read (I think there is an RFC coming as well, so there's definitely room for changes). And my understanding is that the resource does refresh whenever any of the dependent signals change (there is also an imperative refresh() method that can be called on the resource)

    • @mfpears
      @mfpears 2 месяца назад

      @@JoshuaMorony that would be good news

    • @mfpears
      @mfpears 2 месяца назад

      Then we could create a new version of toSignal around this, right?

    • @JoshuaMorony
      @JoshuaMorony  2 месяца назад

      ​@@mfpears you want a lazy toSignal right? I don't really know what the Angular teams thinking around it is at the moment but there was some discussion here: github.com/angular/angular/issues/55337 around the toLazySignal implementation in ngxtension: ngxtension.netlify.app/utilities/signals/to-lazy-signal/

  • @zero14111990
    @zero14111990 2 месяца назад +2

    with this i think i can remove rxjs. yeah this will change a lot my code but better than sorry XD

  • @tinnick
    @tinnick Месяц назад

    Nah 😅. I like where signals are going but this doesn’t feel better.
    Add to the fact that the current state of signals will always be reliant on change detection, this is going to take a little bit more time to grow on me.

  • @MichaelLazarski
    @MichaelLazarski 2 месяца назад +1

    i can't wait to get rid of rxjs and this will help a lot! can't wait to update to angular 19!

    • @hengkeatyam3700
      @hengkeatyam3700 2 месяца назад +1

      why?

    • @MichaelLazarski
      @MichaelLazarski 2 месяца назад +1

      @@hengkeatyam3700 a pain to get rxjs "right" and onboarding new people to it is a pain. it bleeds everywhere and you need to use it then everywhere. Singals just look way cleaner and they are way easier to understand then rxjs and rxjs/stores

  • @jeffnikelson5824
    @jeffnikelson5824 2 месяца назад

    jigggo