Publisher-Subscriber Design Pattern in JavaScript | JavaScript Interview Question - 60

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 ธ.ค. 2024

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

  • @AbhishekSingh-pt7mj
    @AbhishekSingh-pt7mj ปีที่แล้ว +2

    I'm loving these designs patterns video . please let them coming sir ❤🎉

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

    Top notch content

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

    Do we also need to handle subscribeOnceCallbacks and subscribeOnceAsyncCallbacks in publishAll method?

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

    Did you made the video for practicing or educating people?

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

      I practice and people can educate watching this.

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

    Hey I have a doubt here about the implementation regarding the prototypal inheritance.
    Isn't when here methods like subscribe, subscribeOnce etc are defined on the Event constructor then each instance of the Event constructor will have it's own copy of methods and that's not ideal.
    Wouldn't it will be better to to define these methods on Events.prototype or use class syntax?

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

      We use constructors to create private instances, if you want shared instance use prototype

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

      Okay thanks,
      Can you give some examples where private instances will make sense and where shared instances will make more sense?

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

      @@9709923699 if you to share the data have shared instance. For example sending notification, you want same instance to be used everywhere thus share it