-
Notifications
You must be signed in to change notification settings - Fork 28
Store a class instead of an instance #20
Comments
I'm interested in this as well. If i my module's factory returns a class, it is not possible to normally use the class. intravenous forces me to call |
@mathieug Why would you want to do it anyways? @derhuerst |
@tusharmath I just think intravenous does an unnecessary thing here. Besides limiting me in how to use the class, it also introduces more complexity in the code base. I'd like it to just return the class. |
I don't mean to self promote, but node-ioc is something that can help you create custom factories. const IOC = require('node-ioc')
const container = new IOC()
class SampleClass {}
// register takes a factory function for SampleClass
container.register(() => SampleClass).as(SampleClass)
container.resolve(SampleClass) // returns the class and not the instance. |
I would like Intravenous to Store a class but return a NEW instance on every call to container.get('..') . |
Just like @tusharmath did, I will promote my own DI framework flacon. |
This is probably a good place to point out that I'd recommend you take a look at the libraries shamelessly promoted by the others :) As you may be able to tell from the commit logs I'm not really actively developing this library anymore since I don't really have the need for it anymore. |
Out of curiosity, what is the reason for why you don't need this library anymore? |
let me guess, you too have moved to reactive programming ? :) |
Well, for server-side stuff I'm doing Java mostly nowadays and client-side I think ES6 modules are a pretty decent alternative, especially combined with React/Redux. You don't need dependencies accessible from everywhere, instead you only (mostly) need them in the reducers and then they're just a |
How to store a class instead an instance?
The text was updated successfully, but these errors were encountered: