mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[Fizz/Flight] Don't use default args (#21681)
* Don't use default args * Hoist out creation for better inlining The closures prevent inlining otherwise.
This commit is contained in:
+12
-4
@@ -42,12 +42,12 @@ type Controls = {|
|
||||
startWriting(): void,
|
||||
|};
|
||||
|
||||
function pipeToNodeWritable(
|
||||
function createRequestImpl(
|
||||
children: ReactNodeList,
|
||||
destination: Writable,
|
||||
options?: Options,
|
||||
): Controls {
|
||||
const request = createRequest(
|
||||
options: void | Options,
|
||||
) {
|
||||
return createRequest(
|
||||
children,
|
||||
destination,
|
||||
createResponseState(options ? options.identifierPrefix : undefined),
|
||||
@@ -57,6 +57,14 @@ function pipeToNodeWritable(
|
||||
options ? options.onCompleteAll : undefined,
|
||||
options ? options.onReadyToStream : undefined,
|
||||
);
|
||||
}
|
||||
|
||||
function pipeToNodeWritable(
|
||||
children: ReactNodeList,
|
||||
destination: Writable,
|
||||
options?: Options,
|
||||
): Controls {
|
||||
const request = createRequestImpl(children, destination, options);
|
||||
let hasStartedFlowing = false;
|
||||
startWork(request);
|
||||
return {
|
||||
|
||||
+11
-8
@@ -222,17 +222,20 @@ export function createRequest(
|
||||
destination: Destination,
|
||||
responseState: ResponseState,
|
||||
rootFormatContext: FormatContext,
|
||||
progressiveChunkSize: number = DEFAULT_PROGRESSIVE_CHUNK_SIZE,
|
||||
onError: (error: mixed) => void = defaultErrorHandler,
|
||||
onCompleteAll: () => void = noop,
|
||||
onReadyToStream: () => void = noop,
|
||||
progressiveChunkSize: void | number,
|
||||
onError: void | ((error: mixed) => void),
|
||||
onCompleteAll: void | (() => void),
|
||||
onReadyToStream: void | (() => void),
|
||||
): Request {
|
||||
const pingedTasks = [];
|
||||
const abortSet: Set<Task> = new Set();
|
||||
const request = {
|
||||
destination,
|
||||
responseState,
|
||||
progressiveChunkSize,
|
||||
progressiveChunkSize:
|
||||
progressiveChunkSize === undefined
|
||||
? DEFAULT_PROGRESSIVE_CHUNK_SIZE
|
||||
: progressiveChunkSize,
|
||||
status: BUFFERING,
|
||||
nextSegmentId: 0,
|
||||
allPendingTasks: 0,
|
||||
@@ -243,9 +246,9 @@ export function createRequest(
|
||||
clientRenderedBoundaries: [],
|
||||
completedBoundaries: [],
|
||||
partialBoundaries: [],
|
||||
onError,
|
||||
onCompleteAll,
|
||||
onReadyToStream,
|
||||
onError: onError === undefined ? defaultErrorHandler : onError,
|
||||
onCompleteAll: onCompleteAll === undefined ? noop : onCompleteAll,
|
||||
onReadyToStream: onReadyToStream === undefined ? noop : onReadyToStream,
|
||||
};
|
||||
// This segment represents the root fallback.
|
||||
const rootSegment = createPendingSegment(request, 0, null, rootFormatContext);
|
||||
|
||||
+2
-2
@@ -98,7 +98,7 @@ export function createRequest(
|
||||
model: ReactModel,
|
||||
destination: Destination,
|
||||
bundlerConfig: BundlerConfig,
|
||||
onError: (error: mixed) => void = defaultErrorHandler,
|
||||
onError: void | ((error: mixed) => void),
|
||||
): Request {
|
||||
const pingedSegments = [];
|
||||
const request = {
|
||||
@@ -113,7 +113,7 @@ export function createRequest(
|
||||
completedErrorChunks: [],
|
||||
writtenSymbols: new Map(),
|
||||
writtenModules: new Map(),
|
||||
onError,
|
||||
onError: onError === undefined ? defaultErrorHandler : onError,
|
||||
flowing: false,
|
||||
toJSON: function(key: string, value: ReactModel): ReactJSONValue {
|
||||
return resolveModelToJSON(request, this, key, value);
|
||||
|
||||
Reference in New Issue
Block a user