Skip to content

Commit

Permalink
Promote ASYNC_ITERATOR symbol to React Symbols
Browse files Browse the repository at this point in the history
So that if we end up referring to it in more places, it's only one.
  • Loading branch information
sebmarkbage committed Apr 16, 2024
1 parent 7909d8e commit 0fbb944
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
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;

0 comments on commit 0fbb944

Please sign in to comment.