Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promote ASYNC_ITERATOR symbol to React Symbols #28851

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/react-client/src/ReactFlightClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import {
REACT_LAZY_TYPE,
REACT_ELEMENT_TYPE,
REACT_POSTPONE_TYPE,
ASYNC_ITERATOR,
} from 'shared/ReactSymbols';

export type {CallServerCallback, EncodeFormActionCallback};
Expand Down Expand Up @@ -1245,8 +1246,6 @@ function startReadableStream<T>(
resolveStream(response, id, stream, flightController);
}

const ASYNC_ITERATOR = Symbol.asyncIterator;

function asyncIterator(this: $AsyncIterator<any, any, void>) {
// Self referencing iterator.
return this;
Expand Down
3 changes: 1 addition & 2 deletions packages/react-server/src/ReactFlightServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ import {
REACT_LAZY_TYPE,
REACT_MEMO_TYPE,
REACT_POSTPONE_TYPE,
ASYNC_ITERATOR,
} from 'shared/ReactSymbols';

import {
Expand Down Expand Up @@ -201,8 +202,6 @@ if (

const ObjectPrototype = Object.prototype;

const ASYNC_ITERATOR = Symbol.asyncIterator;

type JSONValue =
| string
| boolean
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/ReactSymbols.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,5 @@ export function getIteratorFn(maybeIterable: ?any): ?() => ?Iterator<any> {
}
return null;
}

export const ASYNC_ITERATOR = Symbol.asyncIterator;