Calls to module.get(...) should be memoized. This effectively turns everything injectable into singletons.
It should be safe to create a factory function (or constructor function) and know that it will only be called once.
Are there times when we wouldn't want singletons? I can't think of any off the top of my head, and it should be simple enough to get the desired behavior by having a singleton factory that creates instances.
Calls to
module.get(...)
should be memoized. This effectively turns everything injectable into singletons.It should be safe to create a factory function (or constructor function) and know that it will only be called once.
Are there times when we wouldn't want singletons? I can't think of any off the top of my head, and it should be simple enough to get the desired behavior by having a singleton factory that creates instances.