Diosaur is a library which allows you to declare objects and services as dependencies to other objects and services and so on, building your application with ease while it takes care of managing them for you.
WARNING
This library requires typescript to work as it is based on Annotations.
import 'reflect-metadata';
import { Service, Parameter, Inject, setParameter, getContainer } from 'diosaur';
@Service()
class Doggo {
constructor(@Parameter('doggoName') private name: string) {}
bark() {
return this.name.toUpperCase();
}
}
@Service()
class JonSnow {
@Inject()
private doggo: Doggo;
yell() {
return `I'm Jon with my doggo ${this.doggo.bark()} !`;
}
}
setParameter('doggoName', 'Ghost');
getContainer().then((container) => {
const jon = container.get(JonSnow);
console.log(jon.yell());
});