isRecording
Return if the current code exists between a start and stop call.
ObservationRecorder.isRecording()
Return if the current code exists between a start and stop call.
ObservationRecorder.isRecording(); //-> false
ObservationRecorder.start();
ObservationRecorder.isRecording(); //-> true
ObservationRecorder.stop();
Returns
{Boolean}
:
True if something is in the process of recording observes.
Use Cases
.isRecording
can be used to optimize libraries like can-observation so they preemptively
setup their cached value when being read within something that is likely to bind to themselves.
For example, can-observation's .get
uses this to preemptively bind to itself if its going to be bound later:
{
get: function() {
if ( ObservationRecord.isRecording() && !this.bound ) {
temporarilyBind( this );
}
if ( this.bound ) {
return this.cachedValue;
} else {
// run the function
return this.fn.call( this.context );
}
}
}