@@ -29,6 +29,7 @@ var dispatchSymbol = canSymbol.for("can.dispatch");
29
29
// this work.
30
30
31
31
var peekValue = ObservationRecorder . ignore ( canReflect . getValue . bind ( canReflect ) ) ;
32
+ var peekGet = ObservationRecorder . ignore ( Observation . prototype . get ) ;
32
33
33
34
var getFastPathRoot = ObservationRecorder . ignore ( function ( computeData ) {
34
35
if ( computeData . reads &&
@@ -112,6 +113,10 @@ var ScopeKeyData = function(scope, key, options){
112
113
var valueDependencies = new Set ( ) ;
113
114
valueDependencies . add ( observation ) ;
114
115
this . dependencies = { valueDependencies : valueDependencies } ;
116
+
117
+ // This is basically what .get() should give, but it
118
+ // isn't used to figure out the last value.
119
+ this . _latestValue = undefined ;
115
120
} ;
116
121
117
122
valueEventBindings ( ScopeKeyData . prototype ) ;
@@ -128,7 +133,7 @@ assign(ScopeKeyData.prototype, {
128
133
constructor : ScopeKeyData ,
129
134
dispatch : function dispatch ( newVal ) {
130
135
var old = this . value ;
131
- this . value = newVal ;
136
+ this . _latestValue = this . value = newVal ;
132
137
// call the base implementation in can-event-queue
133
138
this [ dispatchSymbol ] . call ( this , this . value , old ) ;
134
139
} ,
@@ -141,7 +146,7 @@ assign(ScopeKeyData.prototype, {
141
146
// rewrite the observation to call its event handlers
142
147
this . toFastPath ( fastPathRoot ) ;
143
148
}
144
- this . value = peekValue ( this . observation ) ;
149
+ this . _latestValue = this . value = peekGet . call ( this . observation ) ;
145
150
} ,
146
151
onUnbound : function onUnbound ( ) {
147
152
this . bound = false ;
@@ -168,10 +173,10 @@ assign(ScopeKeyData.prototype, {
168
173
}
169
174
}
170
175
171
- if ( this . bound === true ) {
172
- return this . value ;
176
+ if ( this . bound === true && this . fastPath === true ) {
177
+ return this . _latestValue ;
173
178
} else {
174
- return this . observation . get ( ) ;
179
+ return peekGet . call ( this . observation ) ;
175
180
}
176
181
} ,
177
182
toFastPath : function ( fastPathRoot ) {
@@ -188,6 +193,7 @@ assign(ScopeKeyData.prototype, {
188
193
// but I think we will be able to get at it b/c there should only be one
189
194
// dependency we are binding to ...
190
195
if ( target === fastPathRoot && typeof newVal !== "function" ) {
196
+ self . _latestValue = newVal ;
191
197
this . newVal = newVal ;
192
198
} else {
193
199
// restore
0 commit comments