codedamn

Singleton

Created by Piyush Garg about a year ago

0

No description provided

5 Comments

    1

    Is there a way to do the same thing without singleton? If I am not creating a service(class) but just a normal async function which created a socket connection

    @keshavm

    keshavm

    @keshavm

    3

    I'm used to use useRef on App to save and reuse previous connection. Making "new" operation doesn't return new instance is really new idea to me, will try that on my project :)

    @wilsoncheng

    Wilson Cheng

    @wilsoncheng

    0

    best explanation ever on internet.

    @ggggg

    gthere

    @ggggg

    0

    Thanks Bhaiya

    @ankushladani

    Ankush Ladani

    @ankushladani

    0

    But what's wrong with React.useEffect if we give dependency array as empty? Wont it work then because then it will establish the connection only once?

    @1kaushik1

    Kaushik Mazumdar

    @1kaushik1

Your comment