日期:2014-05-16  浏览次数:20443 次

Ext js 4, 越来越像ruby
玩了会extjs4,总体觉得商业化越来越重,写法上越来越像ruby

1.Dynamic loading
使用requires标识依赖,然后自动加载,跟ruby中的require很相似,不过好像还没有实现auto load,这是迟早的事,javascript中只要结合coc实现这个应该很容易

2.Mixins
Ext.define('Sample.Musician', {
    extend: 'Sample.Person',

    mixins: {
        guitar: 'Sample.ability.CanPlayGuitar',
        compose: 'Sample.ability.CanComposeSongs',
        sing: 'Sample.ability.CanSing'
    }
});

mixin在ruby中就是include

3.Statics
用Statics定义静态方法,相当于ruby中的类方法

4.Model
// GET /users/123
User.load(123, {
    success: function(user) {
        console.log(user.get('name')); //"Aaron Conran"
        console.log(user.orders().getCount()); //"1" -- there is only 1 order in the response above
 
        //we can iterate over the orders easily using the Associations API
        user.orders().each(function(order) {
            console.log(order.get('status')); //"shipped"
 
            //we can even iterate over each Order's OrderItems:
            order.orderItems().each(function(orderItem) {
                console.log(orderItem.get('title')); //"Sencha Touch"
            });
        });
    }
});

总体来说因为语法的限制,写得没有ruby简略,不过基本上已经可以实现activerecord了
把rest服务端当做数据库来使用

5.mvc
已经提出mvc的概念,写法上很像rails

6.主题和css可以使用sass来定义