ecowden / pluto.js

JavaScript Dependency Injection
MIT License
8 stars 3 forks source link

Memoize #12

Closed ecowden closed 10 years ago

ecowden commented 10 years ago

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.