mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
f4e974d26e
* Add Flight Build and Unify HostFormat Config between Flight and Fizz * Add basic resolution of models * Add basic Flight fixture Demonstrates the streaming protocol. * Rename to flight-server to distinguish from the client parts * Add Flight Client package and entry point * Fix fixture
31 lines
753 B
JavaScript
31 lines
753 B
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its 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 {ReactNodeList} from 'shared/ReactTypes';
|
|
import type {Writable} from 'stream';
|
|
|
|
import {createRequest, startWork, startFlowing} from 'react-server/inline.dom';
|
|
|
|
function createDrainHandler(destination, request) {
|
|
return () => startFlowing(request, 0);
|
|
}
|
|
|
|
function pipeToNodeWritable(
|
|
children: ReactNodeList,
|
|
destination: Writable,
|
|
): void {
|
|
let request = createRequest(children, destination);
|
|
destination.on('drain', createDrainHandler(destination, request));
|
|
startWork(request);
|
|
}
|
|
|
|
export default {
|
|
pipeToNodeWritable,
|
|
};
|