@@ -25,35 +25,33 @@ function Binding (compiler, key, isExp, isFn) {
25
25
var BindingProto = Binding . prototype
26
26
27
27
/**
28
- * Process the value, then trigger updates on all dependents
28
+ * Update value and queue instance updates.
29
29
*/
30
30
BindingProto . update = function ( value ) {
31
- this . value = value
32
- batcher . queue ( this , 'update' )
31
+ if ( arguments . length ) this . value = value
32
+ batcher . queue ( this )
33
33
}
34
34
35
+ /**
36
+ * Actually update the instances.
37
+ */
35
38
BindingProto . _update = function ( ) {
36
- var i = this . instances . length
39
+ var i = this . instances . length ,
40
+ value = this . eval ( )
37
41
while ( i -- ) {
38
- this . instances [ i ] . update ( this . value )
42
+ this . instances [ i ] . update ( value )
39
43
}
40
44
this . pub ( )
41
45
}
42
46
43
47
/**
44
- * -- computed property only --
45
- * Force all instances to re-evaluate themselves
48
+ * Return the valuated value regardless
49
+ * of whether it is computed or not
46
50
*/
47
- BindingProto . refresh = function ( ) {
48
- batcher . queue ( this , 'refresh' )
49
- }
50
-
51
- BindingProto . _refresh = function ( ) {
52
- var i = this . instances . length
53
- while ( i -- ) {
54
- this . instances [ i ] . refresh ( )
55
- }
56
- this . pub ( )
51
+ BindingProto . eval = function ( ) {
52
+ return this . isComputed && ! this . isFn
53
+ ? this . value . $get ( )
54
+ : this . value
57
55
}
58
56
59
57
/**
@@ -63,7 +61,7 @@ BindingProto._refresh = function () {
63
61
BindingProto . pub = function ( ) {
64
62
var i = this . subs . length
65
63
while ( i -- ) {
66
- this . subs [ i ] . refresh ( )
64
+ this . subs [ i ] . update ( )
67
65
}
68
66
}
69
67
0 commit comments