inversify-vanillajs-helpers demo

node v4.9.1
version: 1.0.0
endpointsharetweet
var helpers = require("inversify-vanillajs-helpers").helpers; var inversify = require("inversify"); require("reflect-metadata"); class Katana { constructor() { this.name = "Katana"; } } class Shuriken { constructor() { this.name = "Shuriken"; } } class Ninja { constructor(primaryWeapon, secondaryWeapon) { this.primaryWeapon = primaryWeapon; this.secondaryWeapon = secondaryWeapon; } } let kernel = new inversify.Kernel(); let register = helpers.register(kernel); let TYPE = { Warrior: "Warrior", Weapon: "Weapon" }; register(TYPE.Weapon, [], (b) => b.whenTargetTagged("throwable", false))(Katana); register(TYPE.Weapon, [], (b) => b.whenTargetTagged("throwable", true))(Shuriken); register(TYPE.Warrior, [ { tagged: { key: "throwable", value: false }, type: TYPE.Weapon }, { tagged: { key: "throwable", value: true }, type: TYPE.Weapon } ])(Ninja); kernel.get(TYPE.Warrior);
Loading…

no comments

    sign in to comment