Frame icon indicating copy to clipboard operation
Frame copied to clipboard

Singletons should also be allowed to be instances

Open bugs181 opened this issue 6 years ago • 1 comments

Singletons should also be allowed to be instances when it's fitting. Maybe perhaps determined by initializer. For example a Storage adapter may be a singleton for a specific connection/directory, but another singleton for a different directory. This essentially groups flows into singletons deterministically.

bugs181 avatar Mar 12 '19 08:03 bugs181

I suppose we could leave these up to the blueprint implementations themselves. A top level singleton can choose to create a new instance of itself based on some factor.

Example implementation:

Blueprint = {
   instances: {},
   init: function(props, callback) {
       if (instances[props.path])
           return instances[props.path]

       // Set up a new instance to be shared here.
   }
}

bugs181 avatar Mar 12 '19 08:03 bugs181