Skip to content

Commit 89d6e15

Browse files
committed
renaming things for consistency
1 parent bcaed1d commit 89d6e15

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

packages/react-server-dom-fb/src/__tests__/ReactFlightDOMServerFB-test.internal.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,29 @@ let Suspense;
3131
let registerClientReference;
3232

3333
class Destination {
34+
#buffer = '';
35+
#controller = null;
3436
constructor() {
3537
const self = this;
3638
this.stream = new ReadableStream({
3739
start(controller) {
38-
self._controller = controller;
40+
self.#controller = controller;
3941
},
4042
});
4143
}
4244
write(chunk) {
43-
this._controller.enqueue(chunk);
45+
this.#buffer += chunk;
46+
}
47+
beginWriting() {}
48+
completeWriting() {}
49+
flushBuffered() {
50+
if (!this.#controller) {
51+
throw new Error('Expected a controller.');
52+
}
53+
this.#controller.enqueue(this.#buffer);
54+
this.#buffer = '';
4455
}
4556
close() {}
46-
flush() {}
47-
onStart() {}
48-
onComplete() {}
4957
onError() {}
5058
}
5159

packages/react-server/src/forks/ReactServerStreamConfig.dom-fb-experimental.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,20 @@ import type {
1616
} from '../ReactServerStreamConfigFB';
1717

1818
export interface Destination {
19+
beginWriting(): void;
1920
write(chunk: Chunk | PrecomputedChunk | BinaryChunk): void;
21+
completeWriting(): void;
22+
flushBuffered(): void;
2023
close(): void;
21-
flush(): void;
22-
onStart(): void;
23-
onComplete(): void;
2424
onError(error: mixed): void;
2525
}
2626

2727
export function scheduleWork(callback: () => void) {
2828
callback();
2929
}
3030

31-
export function flushBuffered(destination: Destination) {
32-
destination.flush();
33-
}
3431
export function beginWriting(destination: Destination) {
35-
destination.onStart();
32+
destination.beginWriting();
3633
}
3734

3835
export function writeChunk(
@@ -51,7 +48,11 @@ export function writeChunkAndReturn(
5148
}
5249

5350
export function completeWriting(destination: Destination) {
54-
destination.onComplete();
51+
destination.completeWriting();
52+
}
53+
54+
export function flushBuffered(destination: Destination) {
55+
destination.flushBuffered();
5556
}
5657

5758
export function close(destination: Destination) {

0 commit comments

Comments
 (0)