-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3d635f6
commit 1985eae
Showing
14 changed files
with
100 additions
and
90 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { Kernel, injectable, named, inject } from "inversify"; | ||
import "reflect-metadata"; | ||
|
||
let TYPES = { | ||
Warrior: Symbol("Warrior"), | ||
Weapon: Symbol("Weapon") | ||
}; | ||
|
||
let TAGS = { | ||
katana: "katana", | ||
shuriken: "shuriken", | ||
}; | ||
|
||
interface Weapon {} | ||
|
||
interface Warrior { | ||
katana: Weapon; | ||
shuriken: Weapon; | ||
} | ||
|
||
@injectable() | ||
class Katana implements Weapon {} | ||
|
||
@injectable() | ||
class Shuriken implements Weapon {} | ||
|
||
@injectable() | ||
class Ninja implements Warrior { | ||
|
||
public katana: Weapon; | ||
public shuriken: Weapon; | ||
|
||
public constructor( | ||
@inject(TYPES.Weapon) @named(TAGS.katana) katana: Weapon, | ||
@inject(TYPES.Weapon) @named(TAGS.shuriken) shuriken: Weapon | ||
) { | ||
this.katana = katana; | ||
this.shuriken = shuriken; | ||
} | ||
} | ||
|
||
let kernel = new Kernel(); | ||
|
||
kernel.bind<Warrior>(TYPES.Warrior).to(Ninja); | ||
kernel.bind<Weapon>(TYPES.Weapon).to(Katana).whenTargetNamed(TAGS.katana); | ||
kernel.bind<Weapon>(TYPES.Weapon).to(Shuriken).whenTargetNamed(TAGS.shuriken); | ||
|
||
function useDevtools() { | ||
|
||
let win: any = window; | ||
win.kernel = kernel; | ||
|
||
if (win.__inversifyDevtools__) { | ||
win.__inversifyDevtools__(kernel); | ||
} | ||
|
||
kernel.get("ninja"); | ||
kernel.get(TYPES.Warrior); | ||
kernel.get(TYPES.Weapon); | ||
kernel.getNamed(TYPES.Weapon, TAGS.shuriken); | ||
kernel.getNamed(TYPES.Weapon, TAGS.katana); | ||
|
||
} | ||
|
||
// render("root"); | ||
// setTimeout(() => { useDevtools(); }, 1000); | ||
|
||
export { useDevtools }; |
This file was deleted.
Oops, something went wrong.