-
-
Save justinyoo/6e3b18bbb76ab2f390986e8d837aa55e to your computer and use it in GitHub Desktop.
Using IoC Container in Vue.js and TypeScript App
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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