Questions tagged [singleton]

The singleton is a design pattern to ensure that exactly one application-wide instance of a particular class exists.

11 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
3 votes
0 answers
105 views

JavaScript Singleton Pattern/Class "Methods"

I have a library that will be called in multiple places. Here is my implementation: var vessel1 = new Vessel(); var vessel2 = new Vessel(); ...
Lansana's user avatar
  • 387
3 votes
0 answers
221 views

Threadsafe singleton factory to use in Apache thrift server RPC system

My goal was to write a factory that the code did not have to be edited. Thus I am registering my factory functions into a singleton factory. I am going to be using this code in Apache thrift server ...
user249806's user avatar
2 votes
0 answers
149 views

SharedPreferences singleton wrapper

I was wondering wether my implementation of the PreferenceService below is thread safe or could cause memory leaks. Android Studio gives me the warning "Do not place Android context classes in ...
nullmn's user avatar
  • 121
2 votes
0 answers
2k views

Singleton pattern for Redis connection

Recently I have learned about singleton design pattern. I have tried to implement Redis connection following singleton design pattern. conn/redis.go ...
Mahmudul Haque's user avatar
2 votes
0 answers
67 views

Generic DialogueBox class with different parameters

I have implemented a DialogueBox class which can be static, singleton, service locator, etc. I have written it as a singleton pattern and implemented it in Unity3d engine. It is a part of a game. I ...
Mahdi's user avatar
  • 121
2 votes
0 answers
48 views

Creating an object handler that loads objects in an array in PHP

I am creating tooltips that I will use throughout my site. Each individual tooltip is created as an object, all of these tooltips need to be ingested with these rules: I should be able to hold an ...
Josh Collins's user avatar
2 votes
0 answers
186 views

Comments on singleton Swift status bar alert

I was trying out some projects like a status bar alert. It made most sense for this status bar to be a singleton: there is only one alert visible at a time. ...
Daniel's user avatar
  • 265
2 votes
0 answers
46 views

Classes to help transform "How hard is it to …?" questions into replies like "It's really hard to …"

I've written a Twitter bot, @answering_yelp, which responds to another Twitter bot, @hard_to_yelp. They scrape yelp reviews for sentences which start "How hard is it to..." and my bot answer with some ...
AJFaraday's user avatar
  • 172
2 votes
0 answers
54 views

Java interface to C library - Refactoring to singleton usage

I am currently writing a Java interface to a C library. It mostly just delegates calls and adds a object oriented layer on top of it to make integration into a regular Java program more natural. The ...
Luca Fülbier's user avatar
1 vote
0 answers
562 views

Creating a logger in the top level of my react app and then using it in other components as I need it

...
Andreas Andreou's user avatar
1 vote
0 answers
1k views

JavaScript to connect to Redis using Singleton

I'm trying to create a class to connect to Redis in Express. I don't think my code is good enough as I got variable db hanging out. ...
toy's user avatar
  • 831