Share the work | RxJS Tutorials

Поділитися
Вставка
  • Опубліковано 26 жов 2024

КОМЕНТАРІ • 12

  • @senburbensgaming
    @senburbensgaming 2 роки тому

    Keep making videos like this on rxjs concepts and use cases in useful scenarios

  • @yapayzeka
    @yapayzeka 2 роки тому

    watched couple videos and this one is the best. ne need to watch any videos about share operator after this amazing video. thank you very much.

  • @corneasp9418
    @corneasp9418 Місяць тому

    Can `share` cause memory leaks like `shareReplay`?

  • @dharashah7385
    @dharashah7385 3 роки тому

    Thank you for your guidance...can you make one video for difference between behaviour subject and observable?

    • @CodeWithGio
      @CodeWithGio  3 роки тому +1

      Even though this exact video is not there if you watch the entire series, you'll understand the differences. Also there is video about comparing different subjects

  • @bluejimmy168
    @bluejimmy168 3 роки тому +2

    What do you mean when you say the subscribers are gone at 10:21? I thought the only way for subscribers to be gone are when they unsubscribe. How does share() operator know when the subscribers are gone when none the of subscribers unsubscribe?

    • @CodeWithGio
      @CodeWithGio  3 роки тому +1

      You have to realize that internally share operator keeps track of active subscriptions. How? You know when new subscrption comes, observable gets executed meaning +1 subscription. Also, Inside the observable, you can detect when someone unsubscribes (cleanup function is executed) i.e -1 subsription. So when counter becomes zero, it means no more subscriptions. Please note, this is how I would do it, maybe that is not exact implementation of share operator, but result is the same

    • @CodeWithGio
      @CodeWithGio  3 роки тому +1

      Another note, subscriber doesn't need to unsubscribe explicitly. When observable gets 'completed' it has the same effect as '.unsubscribe' , because cleanup function is executed (same for errors). In this case request observable gets completed when request is done, i.e the one that ajax call returns. Check early videos of the series, I talk a lot about cleanup function

    • @bluejimmy168
      @bluejimmy168 3 роки тому

      @@CodeWithGio oh ok. Can you tell me if I understand this correctly? If the ajax call takes zero time to complete like instantaneously then it would send 3 network calls. The only reason it doesn't is because ajax takes a little time to complete. At 13:34, you use setTimeout to 2000 ms so that the first ajax can be completed then start a second ajax. If you use setTimeout to 15 ms and the first ajax hasnt been completed then it would only be one network call instead of two?

    • @bluejimmy168
      @bluejimmy168 3 роки тому

      @@CodeWithGio Btw, you have the best rxjs tutorials out of all the youtube videos I have watched, very simple and to the point. I love it. Thank you for the hard work.

    • @CodeWithGio
      @CodeWithGio  3 роки тому +1

      @@bluejimmy168 In theory if ajax call happens instantaneously, then we'll get 3 calls, because every call will be completed instantly before next subscription arrives. But in reality that's not gonna happen. And yes If I set setTimeout to some lower ms, then only one call will happen