zheksoon / dioma Goto Github PK
View Code? Open in Web Editor NEWElegant dependency injection container for vanilla JavaScript and TypeScript
License: MIT License
Elegant dependency injection container for vanilla JavaScript and TypeScript
License: MIT License
At the moment, the .waitAsync
waits for the next tick, which is slower. I think it's possible to build a chain of async resolutions with final resolution to resolve the method.
That's maybe a nonsensical question.
I instantiate a container for every web request I take in a controller. The container is created inside the web callback, so I don't have access to it in the global scope where I would need it to inject classes in my constructors.
I guess I need to register every class of my app against this instance of a container.
What would be just cool is a way to inject
call in my classes constructor against the container used by the parent class.
Does that even make sense ? And if so, is that maybe too much magic ?
Promising projact anyway, I have been looking for a no-nonsense DI lib for some time (even built one myself). My goal is to use it in the context of cloudflare workers, where env and services are injected as parameters to the initial fetch call.
At the moment factory arguments are any[]
. While I think the factory arguments aren't used that often, it might be a good addition.
Bottlejs has a concept of decorator https://github.com/young-steveo/bottlejs?tab=readme-ov-file#decorators that is a function that runs when class / service is instantiated
Currently i use to register event handlers when a class declares one or more
Nice library!
yarn test
returns:
The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.
...followed by success of all tests.
adding "type": "module", to package.json clears the warning.
At the moment factory injection does not have cycle detection as the injection is resolved outside the try/catch where the resolutionSet
is set.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.