Hujs 总结10. knockout.js
• MVVM
• view model
• data and behavior
• view
• DOM binding
• DOM as template
• just change view model to sync with
view
11. knockout.js
• my option
• DOM oriented
• hard to work with javascript newed
component (KISSY)
• behavior and view are not separated
13. Object
• Object.create
• Object.defineProperty
• Object.getPrototype
• Object.keys
• Object.getOwnPropertyDescriptor
• Object.getOwnPropertyName
• Object.seal/preventExtension/freeze ...
19. souce map
• Generated by closure compiler. Intro
• native support in chrome
• 调试压缩/翻译代码
• used at KISSY XTemplate
//@ sourceMappingURL=/path/to/file.js.map
or
X-SourceMap: /path/to/file.js.map
20. KISSY XTemplate
var tpl = 'this is {{title}}!';
var data = {
title: 'o'
};
var render = new XTemplate(tpl, {
name: 'tpl-variable'
}).render(data);
24. Promise
• cleaner method signature
• nested call changed to chained call
io.get("url1").then(function(){
return io.get("url2")
io.get("url1",function(){
io.get('url2',function(){
}).then(function(){
io.get('url3',function(){
});
return io.get("url3");
});
})
}).then(function(data3){
});
27. Promise
• error bubble
io.get("url1").then(function(){
return io.get("url2")
}).then(function(){
return io.get("url3");
}).then(function(data3){
},function(err){
alert(error);
});
28. Promise
• error recovery
io.get("url1").then(function () {
return io.get("url2");
}, function (e) {
// error recovery
S.log(e);
return io.get("url2");
}).then(function (data2) {
});
32. 常用模块
• async
• 方便异步操作
• log4js
• 日志
• node-webkit-agent
• 使用 chrome dev tools 监控服务器端
38. game vs web
• area based vs load balance
• state vs stateless
• broadcast (area) vs request / response
• tick vs request
43. 调优
• console.time / timeEnd
• benchmark.js 性能测量
• top / iotop @linux
• node-webkit-agent
• v8profile
• nodejs gc log -> jvm gc log