Upgrade to Pro — share decks privately, control downloads, hide ads and more …

【懒懒之道】之轻分享《淘宝观光团hujs总结》——承玉

d2forum
September 29, 2012
570

 【懒懒之道】之轻分享《淘宝观光团hujs总结》——承玉

d2forum

September 29, 2012
Tweet

Transcript

  1. knockout.js • MVVM • view model • data and behavior

    • view • DOM binding • DOM as template • just change view model to sync with view 12年9月21⽇日星期五
  2. knockout.js • my option • DOM oriented • hard to

    work with javascript newed component (KISSY) • behavior and view are not separated 12年9月21⽇日星期五
  3. Object • Object.create • Object.defineProperty • Object.getPrototype • Object.keys •

    Object.getOwnPropertyDescriptor • Object.getOwnPropertyName • Object.seal/preventExtension/freeze ... 12年9月21⽇日星期五
  4. Array • every • some • map • filter •

    forEach • reduce • indexOf ... 12年9月21⽇日星期五
  5. JSON • stringify(value,[ [replacer],space]) • parser(text,[reviver]) • subset of javascript

    • double quote • not support \x 12年9月21⽇日星期五
  6. ‘use strict’; • 禁⽌止不声明的变量 • 禁⽌止 with • 全局 eval

    • arguments 不同步参数 • 禁⽌止 caller callee • 禁⽌止对象重复属性名 12年9月21⽇日星期五
  7. 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 12年9月21⽇日星期五
  8. KISSY XTemplate var  tpl  =  'this  is  {{title}}!'; var  data

     =  {        title:  'o' }; var  render  =  new  XTemplate(tpl,  {        name:  'tpl-­‐variable' }).render(data); 12年9月21⽇日星期五
  9. Promise • cleaner method signature • nested call changed to

    chained call io.get("url1",function(){        io.get('url2',function(){                io.get('url3',function(){                });        }); }) io.get("url1").then(function(){    return  io.get("url2") }).then(function(){    return  io.get("url3");   }).then(function(data3){ }); 12年9月21⽇日星期五
  10. Promise • easy combination • easy parallel • S.Promise.all(  

    io.get('url1'), io.get('url2'), function(  data1,  data2  ){ }); 12年9月21⽇日星期五
  11. Promise • exception-bullet • io.get('url').then(function(){        throw  "2";

    }).fail(function(w){        alert(w);   }); 12年9月21⽇日星期五
  12. 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);     }); 12年9月21⽇日星期五
  13. 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)  { }); 12年9月21⽇日星期五
  14. 常⽤用模块 • async • ⽅方便异步操作 • log4js • ⽇日志 •

    node-webkit-agent • 使⽤用 chrome dev tools 监控服务器端 12年9月21⽇日星期五
  15. game vs web • area based vs load balance •

    state vs stateless • broadcast (area) vs request / response • tick vs request 12年9月21⽇日星期五
  16. 调优 • console.time / timeEnd • benchmark.js 性能测量 • top

    / iotop @linux • node-webkit-agent • v8profile • nodejs gc log -> jvm gc log 12年9月21⽇日星期五
  17. cloud • appfog • azure • npm install azure •

    git commit • git push azure master 12年9月21⽇日星期五