-
-
Notifications
You must be signed in to change notification settings - Fork 10
Description
Is your feature request related to a problem? Please describe.
Simple singleton can be implemented via private property _instance and a public one named Instance. Once created, it holds reference to the targeted object over application lifetime until termination.
WeakReference can be used in cases when there is no need to hold object reference over long time. Its target can be deleted with garbage collector in short period of time. Correct implementation of Singleton over WeakReference is not hard but repeatitive.
Describe the solution you'd like
Implement WeakSingleton that holds singleton logic over WeakReference.
Describe alternatives you've considered
Dependency injection is a great alternative and a preferred one. But in cases where there is no DI in some projects and importing DI features to those projects is painful or just overhead, it is useful to have that sort of custom singleton implementation,