const { radis } = require('radis');
class Unicorn {
constructor(name) {
this.name = name;
}
poop() {
console.log(`${this.name} poop rainbow`);
}
}
class UnicornProvider {
constructor($injector, name) {
this.name = name;
}
setName(name) {
this.name = name;
}
$get() {
return new Unicorn(this.name);
}
}
radis
.module('app', [])
.provider('alice', UnicornProvider)
.provider('anonymousUnicorn', UnicornProvider)
.config((anonymousUnicornProvider) => anonymousUnicornProvider.setName("paul"))
.run((alice, anonymousUnicorn) => {
alice.poop(); // alice poop rainbow
anonymousUnicorn.poop(); // paul poop rainbow
})
.bootstrap()
;
Radis use ES6 syntax internally so it require node >= 6.