Frame
Frame copied to clipboard
Singletons should also be allowed to be instances
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.
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.
}
}