Security News
UK Officials Consider Banning Ransomware Payments from Public Entities
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
@odinjs/odin
Advanced tools
ODIN (On-demand Dependency InjectioN) is a Dependency Injection library inspired by Java CDI, enabling lazy loading pattern on JavaScript applications, providing every resource on-demand.
Dependency Injection (DI) is a technique used to reduce programmer's concern about objects creation and life-cycle. Delegating the management to DI, is possible to build a flexible coupling among resources and parts of the application.
When injecting a resource through the DI, it's only necessary think about how to use, neither about how it is provided or discarded - and well, that is why ODIN has born.
Besides of the lazy load, the resources are only instantiated when necessary. It means that even when a class is instantiated, not necessarily its dependencies were as well. By providing the dependencies at the last possible moment a lot of computational resource are saved, reducing the application requirements and extending the useful life time.
Another feature available is the possiblity to create a CustomProvider, customizing dependencies and the way that these ones are provided.
ODIN was built in Javascript, but uses decorators
- an Stage 2 proposal from tc39 - to create a better experience on providing dependencies.
Since that decorators
is not nativally supported by browsers or node, projects using ODIN will depends on babel and decorators pollifyl (legacy mode).
To use ODIN, execute:
$ npm i --save @odinjs/odin
To use ODIN is simple. Define a dependecy and inject it in another class. 🙃
import { Injectable, Singleton } from '@odinjs/odin';
@Singleton
class MyDependency {
sayHi() {
console.log(`Hi, I'm a potato!!`);
}
}
@Injectable
class AnotherDependency {
@Inject
myDependency;
doSomething() {
this.myDependency.sayHi();
}
}
To initialize the dependency injector, it's necessary to create a container - that will provide dependencies instances.
import odin from '@odinjs/odin';
// creates a container based on root bundle
const container = odin.container();
// container is responsible to provide and manage all dependencies
const intance = container.provide(AnotherDependency.name);
// using provided dependency, that will use antoher dependency inside
instance.doSomething();
To make the better use of ODIN, you could read our wiki.
See issues.
Please refer to our Contribution Guide for instructions on how to setup the development environment.
Join us on our Slack channel.
Thiago Teixeira thiago.teixeira@philips.com
2.0.0 (2023-06-20)
action
, state
and any other methods that start with on
. Binding must be done by
the user, as odin
should not be responsible for choosing which
methods should be bound.unregister
to deregister
of the Bundle
and Registry
classes. The removal is now done using the definition
itself, so the args
argument has been removed.FAQs
On-demand dependency injection
The npm package @odinjs/odin receives a total of 120 weekly downloads. As such, @odinjs/odin popularity was classified as not popular.
We found that @odinjs/odin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.