更新时间:2022-06-24 22:36:09
在这种情况下如何整合IOC解决方案
How would I integrate IOC solution in such case
这是我推荐的一个非常受欢迎的库: https://github.com/inversify/InversifyJS
Here is a very popular library that I recommend : https://github.com/inversify/InversifyJS
使用外部模块根本不会更改代码.代替
Using external modules doesn't change the code at all. Instead of
kernel.bind(new TypeBinding<FooBarInterface>("FooBarInterface", FooBar));
您只有
import {ProdFooBar} from "./prodFooBar";
kernel.bind(new TypeBinding<FooBarInterface>("FooBarInterface", ProdFooBar));
import {MockFooBar} from "./mockFooBar";
kernel.bind(new TypeBinding<FooBarInterface>("FooBarInterface", MockFooBar));