-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.js
56 lines (36 loc) · 959 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
var Backbone = require('./index.js');
//console.log('1',Backbone.Model.extend);
var testMDL = Backbone.Model.extend({
computedFields: true,
defaults:{
id:null,
date:null,
amount:1.00,
count:1
},
initialize: function(){
//console.log('init done!');
},
computed:{
itemTotal:{
depends:['amount','count'],
get: function(fields){
return fields.amount * fields.count;
}
}
}
});
console.time("1");
for(var x=0;x<1;x++) {
var t = new testMDL({amount: 12.12});
t.listenTo(t,'change:itemTotal', function (mdl) {
console.log('new itemTotal', mdl.get('itemTotal'));
});
//console.log(t.get('itemTotal'));
t.set('count', 23);
t.set('itemTotal',44444444);
t.set('amount', 1.75);
//console.log(t.get('itemTotal'));
console.log(t.toJSON());
}
console.timeEnd("1");