Create a gist now

Instantly share code, notes, and snippets.

@justinyoo /warriors.ts Secret
Created Mar 21, 2017

What would you like to do?
Using IoC Container in Vue.js and TypeScript App
// models/Warrior.ts
import { inject, injectable } from "inversify";
import SERVICE_IDENTIFIER from "./Identifiers";
import Warrior from "../interfaces/Warrior";
import Weapon from "../interfaces/Weapon";
@injectable()
class Ninja implements Warrior {
public constructor(
@inject(SERVICE_IDENTIFIER.WEAPON) weapon: Weapon
) {
this.name = "Ninja";
this.weapon = weapon;
}
public name: string;
public weapon: Weapon;
}
@injectable()
class Samurai implements Warrior {
public constructor(
@inject(SERVICE_IDENTIFIER.WEAPON) weapon: Weapon
) {
this.name = "Samurai";
this.weapon = weapon;
}
public name: string;
public weapon: Weapon;
}
export { Ninja, Samurai };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment