Singleton design pattern | Frontend System Design Question

แชร์
ฝัง
  • เผยแพร่เมื่อ 17 ก.ย. 2024

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

  • @VivekChavan-ov3pl
    @VivekChavan-ov3pl ปีที่แล้ว +3

    Make a playlist on design patterns in react,

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

    Thankyou really useful.

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

    for singleton pattern, the problem is it does not hold values as 2 different instances of counter does... you can select a better example for this pattern.

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

    as always thankyou for the videos brother,
    I found another possible implementation of singleton design pattern if that might help some of us:
    class Singleton{
    constructor(){
    if(Singleton.instance == null){
    this.logs = [];
    Singleton.instance = this;
    }
    return Singleton.instance;
    }
    log(message){
    this.logs.push(message)
    console.log("Logger logged: ", message);
    }
    printLogCount(){
    console.log("Total Logs are: ", this.logs.length);
    }
    }
    const firstInstanceS = new Singleton();
    const secondInstanceS = new Singleton();
    console.log(firstInstanceS === secondInstanceS);

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

    Thanks for the video 😌

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

    Your website is down