Home / File/ ReactFlightAsyncDispatcher.js — react Source File

ReactFlightAsyncDispatcher.js — react Source File

Architecture documentation for ReactFlightAsyncDispatcher.js, a javascript file in the react codebase. 3 imports, 1 dependents.

File javascript BabelCompiler Validation 3 imports 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  cf774796_4d8c_4065_51db_188d196a7764["ReactFlightAsyncDispatcher.js"]
  e143ec37_0522_ef26_bb9c_180891985523["ReactFlightServer.js"]
  cf774796_4d8c_4065_51db_188d196a7764 --> e143ec37_0522_ef26_bb9c_180891985523
  5e4cdebf_06be_91d3_9e4a_8fec8b4e5b2f["ReactFlightCurrentOwner.js"]
  cf774796_4d8c_4065_51db_188d196a7764 --> 5e4cdebf_06be_91d3_9e4a_8fec8b4e5b2f
  42892443_e223_3da0_aeb9_e1b32a408fb0["ReactInternalTypes"]
  cf774796_4d8c_4065_51db_188d196a7764 --> 42892443_e223_3da0_aeb9_e1b32a408fb0
  e143ec37_0522_ef26_bb9c_180891985523["ReactFlightServer.js"]
  e143ec37_0522_ef26_bb9c_180891985523 --> cf774796_4d8c_4065_51db_188d196a7764
  style cf774796_4d8c_4065_51db_188d196a7764 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 {AsyncDispatcher} from 'react-reconciler/src/ReactInternalTypes';

import {resolveRequest, getCache} from '../ReactFlightServer';
import {resolveOwner} from './ReactFlightCurrentOwner';

function resolveCache(): Map<Function, mixed> {
  const request = resolveRequest();
  if (request) {
    return getCache(request);
  }
  return new Map();
}

export const DefaultAsyncDispatcher: AsyncDispatcher = ({
  getCacheForType<T>(resourceType: () => T): T {
    const cache = resolveCache();
    let entry: T | void = (cache.get(resourceType): any);
    if (entry === undefined) {
      entry = resourceType();
      // TODO: Warn if undefined?
      cache.set(resourceType, entry);
    }
    return entry;
  },
  cacheSignal(): null | AbortSignal {
    const request = resolveRequest();
    if (request) {
      return request.cacheController.signal;
    }
    return null;
  },
}: any);

if (__DEV__) {
  DefaultAsyncDispatcher.getOwner = resolveOwner;
}

Domain

Subdomains

Functions

Dependencies

Frequently Asked Questions

What does ReactFlightAsyncDispatcher.js do?
ReactFlightAsyncDispatcher.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 ReactFlightAsyncDispatcher.js?
ReactFlightAsyncDispatcher.js defines 1 function(s): resolveCache.
What does ReactFlightAsyncDispatcher.js depend on?
ReactFlightAsyncDispatcher.js imports 3 module(s): ReactFlightCurrentOwner.js, ReactFlightServer.js, ReactInternalTypes.
What files import ReactFlightAsyncDispatcher.js?
ReactFlightAsyncDispatcher.js is imported by 1 file(s): ReactFlightServer.js.
Where is ReactFlightAsyncDispatcher.js in the architecture?
ReactFlightAsyncDispatcher.js is located at packages/react-server/src/flight/ReactFlightAsyncDispatcher.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-server/src/flight).

Analyze Your Own Codebase

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

Try Supermodel Free