mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 12:20:20 +01:00
* Return whether to keep flowing in Host config * Emit basic chunk based streaming in the Flight server When something suspends a new chunk is created. * Add reentrancy check The WHATWG API is designed to be pulled recursively. We should refactor to favor that approach. * Basic streaming Suspense support on the client * Add basic suspense in example * Add comment describing the protocol that the server generates
35 lines
732 B
JavaScript
35 lines
732 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/flight.inline-typed';
|
|
|
|
import {
|
|
createRequest,
|
|
startWork,
|
|
startFlowing,
|
|
} from 'react-server/flight.inline.dom-browser';
|
|
|
|
function renderToReadableStream(model: ReactModel): ReadableStream {
|
|
let request;
|
|
return new ReadableStream({
|
|
start(controller) {
|
|
request = createRequest(model, controller);
|
|
startWork(request);
|
|
},
|
|
pull(controller) {
|
|
startFlowing(request);
|
|
},
|
|
cancel(reason) {},
|
|
});
|
|
}
|
|
|
|
export default {
|
|
renderToReadableStream,
|
|
};
|