Giter Club home page Giter Club logo

Comments (10)

derhuerst avatar derhuerst commented on August 30, 2024

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 .get(…) in every place where this class is used. subclassing is also made impossible by this.

from intravenous.

tusharmath avatar tusharmath commented on August 30, 2024

@mathieug Why would you want to do it anyways?

@derhuerst
Define "normally" please. You can use the class directly via require anywhere. May be you should post some more code here.

from intravenous.

derhuerst avatar derhuerst commented on August 30, 2024

@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.

from intravenous.

tusharmath avatar tusharmath commented on August 30, 2024

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.

from intravenous.

vipreshjha avatar vipreshjha commented on August 30, 2024

I would like Intravenous to Store a class but return a NEW instance on every call to container.get('..') .
As currently I get an entry point class in the controller the entry point class which is actually my service has dependencies on other classes and these classes have dependencies on some other class which are injected through their constructors. Intravenous creates the whole graph and gives me the service class. The service class processes the request and returns the result this all falls in line with the strategy of keeping controller as dumb as possible. After returning the result I would like to dispose the service class as some the library classes used by one of its dependencies is leaking. So I have defined "dispose" method on all the classes and in this method set its class variables reference to null and also call the external libraries close() or end() method where ever required. But once I dispose the service class intravenous call the dispose on its cached instance of service class and in the next request or parallel request the dependencies references are all null.

from intravenous.

derhuerst avatar derhuerst commented on August 30, 2024

Just like @tusharmath did, I will promote my own DI framework flacon.

from intravenous.

sagacity avatar sagacity commented on August 30, 2024

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.

from intravenous.

 avatar commented on August 30, 2024

Out of curiosity, what is the reason for why you don't need this library anymore?

from intravenous.

tusharmath avatar tusharmath commented on August 30, 2024

let me guess, you too have moved to reactive programming ? :)

from intravenous.

sagacity avatar sagacity commented on August 30, 2024

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 require away 😋

from intravenous.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.