Do Signals replace RxJS Observables?

Поділитися
Вставка
  • Опубліковано 9 чер 2024
  • 👉 Post: js2brain.com/blog/rxjs-observ...
    Signals recently gained popularity in frontend web development. They are implemented by modern web frameworks like Qwik and SolidJS. Also, Angular adopted them. But what exactly are they, and do they replace RxJS Observables altogether?
    🎓 Website: js2brain.com
    🎵 Music and SFX: ref.audiio.com/kmx6s7zy
    🕐 Timestamps:
    00:00 - Intro
    00:43 - What is a Signal?
    02:43 - What can we do with Signals?
    03:32 - Fine-grained Reactivity
    03:51 - Comparison

КОМЕНТАРІ • 12

  • @LePhenixGD
    @LePhenixGD 3 місяці тому

    Amazing video showcasing signals and their difference with observables
    Btw signals are good for local state management for simple services and RxJS's observables are good for global state management (with NgRx for instance) and HTTP requests

    • @js2brain
      @js2brain  3 місяці тому

      Thanks for your feedback. :)
      And I think you are right.
      Sometimes the HTTP stuff may be overkill though: When you never intend to abort the request, a simple fetch() with Promise does the job.

  • @more-sun
    @more-sun 4 місяці тому

    What is an example of more complex problems that require RxJS?

    • @js2brain
      @js2brain  4 місяці тому +1

      One often mentioned example is an auto completion search. I showed another example over here: ua-cam.com/video/PejF6PhDrT4/v-deo.html&si=nD-K_13i8-G0a1Hs
      Basically everywhere a lot of subscription and unsubscriptions is going on.

    • @yankotliarov9239
      @yankotliarov9239 3 місяці тому +1

      Basically anything that requires syncronuous effects or complex data transformations including integration with old angular api's like router, forms etc.

    • @saeidm4884
      @saeidm4884 3 місяці тому

      I think using merely promises and signals together you can do anything without need for observables.

    • @js2brain
      @js2brain  3 місяці тому

      Sure, you don't even need promises and signals. JavaScript was already turing complete pre-ES6. ;)

  • @wahoobeans
    @wahoobeans 3 місяці тому +1

    So a signal is basically an rxjs subject?

    • @js2brain
      @js2brain  3 місяці тому

      It's similar to the BehaviorSubject, I think. What's different is the subscription mechanism with createEffect(), and Signals are more integrated into the web framework for reactive rendering.

    • @tarquin161234
      @tarquin161234 13 днів тому

      @@js2brain No a signal is not quite like an observable because signals are synchronous, meaning they provide a value from the moment they are created, where as you will probably have to wait for the first value from an observable. You can use toSignal() to go from observable to signal but then you have to initialise it with an arbitrary first value, which may have unexpected side effects.

    • @js2brain
      @js2brain  13 днів тому

      Yeah, as mentioned before, a Signal is more comparable to a BehaviorSubject: initial value, readable, writable, reactive.

  • @developeroppa
    @developeroppa Місяць тому +1

    Repeat after me: Signals & Observables, not Signals vs Observables