Home / File/ EventBatching.js — react Source File

EventBatching.js — react Source File

Architecture documentation for EventBatching.js, a javascript file in the react codebase. 6 imports, 2 dependents.

File javascript BabelCompiler Validation 6 imports 2 dependents 3 functions

Entity Profile

Dependency Diagram

graph LR
  501868ac_ed82_decd_b0b4_e77c7390f910["EventBatching.js"]
  b2f450b6_f67a_153d_5efb_a03735431450["ReactSyntheticEventType.js"]
  501868ac_ed82_decd_b0b4_e77c7390f910 --> b2f450b6_f67a_153d_5efb_a03735431450
  c55ef19d_ffff_0be0_ac25_e6d6c8520cd6["accumulateInto.js"]
  501868ac_ed82_decd_b0b4_e77c7390f910 --> c55ef19d_ffff_0be0_ac25_e6d6c8520cd6
  03d71d90_7e04_8406_8321_a1aeecb7fa15["forEachAccumulated.js"]
  501868ac_ed82_decd_b0b4_e77c7390f910 --> 03d71d90_7e04_8406_8321_a1aeecb7fa15
  c47175ea_4123_c4e5_c30d_de7506f00f3a["EventPluginUtils.js"]
  501868ac_ed82_decd_b0b4_e77c7390f910 --> c47175ea_4123_c4e5_c30d_de7506f00f3a
  220a1380_3b15_b89d_5bbb_e6ffc9e2727a["executeDispatchesInOrder"]
  501868ac_ed82_decd_b0b4_e77c7390f910 --> 220a1380_3b15_b89d_5bbb_e6ffc9e2727a
  d0c6ad93_c095_9236_fd5f_6244a9451913["rethrowCaughtError"]
  501868ac_ed82_decd_b0b4_e77c7390f910 --> d0c6ad93_c095_9236_fd5f_6244a9451913
  846f0667_39ae_eb6e_55fe_26d3acf81e44["ReactFabricEventEmitter.js"]
  846f0667_39ae_eb6e_55fe_26d3acf81e44 --> 501868ac_ed82_decd_b0b4_e77c7390f910
  baab5855_112a_37e6_6ca7_0813fd6ae027["ReactNativeEventEmitter.js"]
  baab5855_112a_37e6_6ca7_0813fd6ae027 --> 501868ac_ed82_decd_b0b4_e77c7390f910
  style 501868ac_ed82_decd_b0b4_e77c7390f910 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 * @flow
 */

import type {ReactSyntheticEvent} from './ReactSyntheticEventType';
import accumulateInto from './accumulateInto';
import forEachAccumulated from './forEachAccumulated';
import {executeDispatchesInOrder, rethrowCaughtError} from './EventPluginUtils';

/**
 * Internal queue of events that have accumulated their dispatches and are
 * waiting to have their dispatches executed.
 */
let eventQueue: ?(Array<ReactSyntheticEvent> | ReactSyntheticEvent) = null;

/**
 * Dispatches an event and releases it back into the pool, unless persistent.
 *
 * @param {?object} event Synthetic event to be dispatched.
 * @private
 */
function executeDispatchesAndRelease(event: ReactSyntheticEvent) {
  if (event) {
    executeDispatchesInOrder(event);

    if (!event.isPersistent()) {
      event.constructor.release(event);
    }
  }
}
// $FlowFixMe[missing-local-annot]
function executeDispatchesAndReleaseTopLevel(e) {
  return executeDispatchesAndRelease(e);
}

export function runEventsInBatch(
  events: Array<ReactSyntheticEvent> | ReactSyntheticEvent | null,
) {
  if (events !== null) {
    eventQueue = accumulateInto(eventQueue, events);
  }

  // Set `eventQueue` to null before processing it so that we can tell if more
  // events get enqueued while processing.
  const processingEventQueue = eventQueue;
  eventQueue = null;

  if (!processingEventQueue) {
    return;
  }

  forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel);

  if (eventQueue) {
    throw new Error(
      'processEventQueue(): Additional events were enqueued while processing ' +
        'an event queue. Support for this has not yet been implemented.',
    );
  }

  // This would be a good time to rethrow if any of the event handlers threw.
  rethrowCaughtError();
}

Domain

Subdomains

Frequently Asked Questions

What does EventBatching.js do?
EventBatching.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in EventBatching.js?
EventBatching.js defines 3 function(s): executeDispatchesAndRelease, executeDispatchesAndReleaseTopLevel, runEventsInBatch.
What does EventBatching.js depend on?
EventBatching.js imports 6 module(s): EventPluginUtils.js, ReactSyntheticEventType.js, accumulateInto.js, executeDispatchesInOrder, forEachAccumulated.js, rethrowCaughtError.
What files import EventBatching.js?
EventBatching.js is imported by 2 file(s): ReactFabricEventEmitter.js, ReactNativeEventEmitter.js.
Where is EventBatching.js in the architecture?
EventBatching.js is located at packages/react-native-renderer/src/legacy-events/EventBatching.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-native-renderer/src/legacy-events).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free