红联Linux门户
Linux帮助

bearcat 0.4.11更新日志,加强热更新功能

发布时间:2015-04-01 12:09:55来源:红联作者:empast
热更新

本次升级主要是加强了热更新功能,添加了对热添加文件、热给对象添加属性依赖的支持

添加文件

直接添加文件,bearcat 会把它动态加入 bearcat IoC 容器中

添加属性依赖

比如之前有这么个bean

app/car.js
var Car = function() {
this.$id = "car";
}

Car.prototype.run = function() {
console.log('run hot car...');
return 'car hot';
}

module.exports = Car;
然后动态给 Car 添加 wheel 的依赖

app/car.js
var Car = function() {
this.$id = "car";
this.$wheel = null;
}

Car.prototype.run = function() {
console.log('run hot car...');
this.$wheel.run();
return 'car hot';
}

module.exports = Car;
直接添加即可,bearcat 会自动解析添加的依赖,并给所有对象实例添加 $wheel 依赖(实现原理是基于动态给prototype链挂上了 $wheel getter 函数)

更多详情还请看官方文档 bearcat hot reload

软件详情:http://bearcatjs.org/topic/index.html

下载地址:https://github.com/bearcatjs/bearcat

来自:开源中国社区
文章评论

共有 0 条评论