Open bugs181 opened 5 years ago
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.
}
}
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.