dispatchInteractiveEvent
来源:8-11 event-事件触发的过程
躁动的胸大肌
2021-02-19
dispatchInteractiveEvent这个方法最终会到的地方是:
let _interactiveUpdatesImpl = function(fn, a, b) {
return fn(a, b);
};
这个函数默认是啥都没有做,后面会重新赋值这个函数,debug的时候是这样的:
function interactiveUpdates$1(fn, a, b) {
if (isBatchingInteractiveUpdates) {
return fn(a, b);
} // If there are any pending interactive updates, synchronously flush them.
// This needs to happen before we read any handlers, because the effect of
// the previous event may influence which handlers are called during
// this event.
if (!isBatchingUpdates && !isRendering && lowestPriorityPendingInteractiveExpirationTime !== NoWork) {
// Synchronously flush pending interactive updates.
performWork(lowestPriorityPendingInteractiveExpirationTime, false);
lowestPriorityPendingInteractiveExpirationTime = NoWork;
}
var previousIsBatchingInteractiveUpdates = isBatchingInteractiveUpdates;
var previousIsBatchingUpdates = isBatchingUpdates;
isBatchingInteractiveUpdates = true;
isBatchingUpdates = true;
try {
return fn(a, b);
} finally {
isBatchingInteractiveUpdates = previousIsBatchingInteractiveUpdates;
isBatchingUpdates = previousIsBatchingUpdates;
if (!isBatchingUpdates && !isRendering) {
performSyncWork();
}
}
}
这个做了啥
写回答
1回答
-
Jokcy
2021-02-21
这个课程里有说到,这里主要设置了批量更新相关的变量
00
相似问题