bearcat 0.3.4 发布 -- 优化依赖注入写法

在 0.3.4 版本中,依赖注入的描述,可以更加的随意,不再强制要求必须是 this.$xxId 的形式

以下的写法也支持

var Car = function() {
    this.$id = "car";
    this["$engine"] = null; // use []
    var wheelName = "$wheel";
    this[wheelName] = null; // use variable
};

Car.prototype["$light"] = null; // use variable in prototype

Car.prototype.run = function() {
    this.$engine.run();
    this.$light.shine();
    this.$wheel.run();
    console.log('car run...');
}

module.exports = Car;

example demo complex_function_annotataion
bearcat官网 bearcatjs.org

相关文章

迭代器模式(Iterator)迭代器模式(Iterator)[Cursor]意图...
高性能IO模型浅析服务器端编程经常需要构造高性能的IO模型,...
策略模式(Strategy)策略模式(Strategy)[Policy]意图:定...
访问者模式(Visitor)访问者模式(Visitor)意图:表示一个...
命令模式(Command)命令模式(Command)[Action/Transactio...
生成器模式(Builder)生成器模式(Builder)意图:将一个对...