UNPKG

next

Version:

The React Framework

29 lines (28 loc) • 1.29 kB
// The sequential implementation of callServer (app-call-server.ts): Server // Actions are dispatched into the sequential router action queue. Callers // must never import this module directly; they import './app-call-server', // which resolves here unless `experimental.concurrentRouterQueue` swaps in // './concurrent-call-server' at the bundler level (see // create-compiler-aliases.ts and next_import_map.rs). // // This module must remain free of side effects at module scope: in addition // to the browser bundle, a statically-resolved copy may be compiled into the // pre-compiled app-page runtime bundles, where the bundler alias cannot // reach. Only the browser copy ever runs. import { startTransition } from 'react'; import { ACTION_SERVER_ACTION } from './components/router-reducer/router-reducer-types'; import { dispatchAppRouterAction } from './components/use-action-queue'; export async function callServer(actionId, actionArgs) { return new Promise((resolve, reject)=>{ startTransition(()=>{ dispatchAppRouterAction({ type: ACTION_SERVER_ACTION, actionId, actionArgs, resolve, reject }); }); }); } //# sourceMappingURL=sequential-call-server.js.map