mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
5fd9db732d
* Move files * Update paths * Rename import variables * Rename /server to /writer This is mainly because "React Server Server" is weird so we need another dimension. * Use "react-server" convention to enforce that writer is only loaded in a server
37 lines
839 B
JavaScript
37 lines
839 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 {ReactModel} from 'react-server/src/ReactFlightServer';
|
|
import type {BundlerConfig} from './ReactFlightServerWebpackBundlerConfig';
|
|
|
|
import {
|
|
createRequest,
|
|
startWork,
|
|
startFlowing,
|
|
} from 'react-server/src/ReactFlightServer';
|
|
|
|
function renderToReadableStream(
|
|
model: ReactModel,
|
|
webpackMap: BundlerConfig,
|
|
): ReadableStream {
|
|
let request;
|
|
return new ReadableStream({
|
|
start(controller) {
|
|
request = createRequest(model, controller, webpackMap);
|
|
startWork(request);
|
|
},
|
|
pull(controller) {
|
|
startFlowing(request);
|
|
},
|
|
cancel(reason) {},
|
|
});
|
|
}
|
|
|
|
export {renderToReadableStream};
|