GithubHelp home page GithubHelp logo

livshitz / di.libx.js Goto Github PK

View Code? Open in Web Editor NEW
32.0 32.0 1.0 61 KB

๐Ÿ’‰ di.libx.js - Lightweight & non intrusive Dependency Injection module that supports async/deferred resolution and uglified support

Home Page: https://livshitz.medium.com/di-libx-js-c2e07a9e919

License: MIT License

Shell 1.95% JavaScript 2.11% TypeScript 95.94%
dependency-injection inversion-of-control javascript library libx nodejs typescript

di.libx.js's Introduction

Hi there ๐Ÿ‘‹

di.libx.js's People

Contributors

adambocco avatar geopic avatar livshitz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

adambocco

di.libx.js's Issues

Syntax highlighting in Readme

Hey, I saw your project on Reddit and was interested in checking it out. I notice your code examples in the Readme don't have colours like you'd find in an IDE. If you want I can make a small contribution to the project by adding syntax highlighting to the code in the Readme so it can be read and understood easier.

Add support for lifetime with sub-container linkage

A DI container instance should be able to get a "parent" container, in which it could search for registered module if not found locally.
Container constructor should be able to get optional parent instance.
The instance reference should be weak, so once the scope/context of the sub container died, GC would clear up the reference, hence will be container's (and its registered modules) lifetime.

Add support in `getParamNames` for different function declaration formats and support class's constructor

So we could get properly the parameters for those variations:

class MyClass {
	constructor(paramA, paramB,  paramC) {}
}
const funcArrow = (paramA, paramB,  paramC) => {};
const funcArrowNoParentheses = paramA => {};
function funcExpression(paramA, paramB,  paramC){};
function functionDouble(paramA, paramB,  paramC){};
const funcSelfExec = ((paramA, paramB, paramC) => {});
function* yieldAndReturn(paramA, paramB, paramC) {}

Add example for real-world how far flung components require distant components

Original question:

How do far flung components get to use di.require(..) ? All the examples are di.register(..) immediately followed by di.require(..)

Answer:

Generally, you're free to decide how you manage the 'master' container singleton, but best practice would be to define myContainer.js, initiate DependencyInjector in it (as show in the examples) and export the container instance.
Anywhere else in the app you should import myContainer.js and require the other dependencies there.

So it'd be best to add such example in code/docs.

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.