From 693be7cd4c358a3b82b608b9b1c502deebbab69d Mon Sep 17 00:00:00 2001 From: Dor Shtaif Date: Thu, 23 Jan 2025 11:02:09 +0200 Subject: [PATCH] fix docs mentions of the current value property from `.current.value` to `.value.current` --- spec/tests/useAsyncIterState.spec.tsx | 2 +- src/common/AsyncIterableChannel.ts | 2 +- src/useAsyncIterState/index.ts | 18 +++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/spec/tests/useAsyncIterState.spec.tsx b/spec/tests/useAsyncIterState.spec.tsx index dc649a8..dfdf2a5 100644 --- a/spec/tests/useAsyncIterState.spec.tsx +++ b/spec/tests/useAsyncIterState.spec.tsx @@ -29,7 +29,7 @@ describe('`useAsyncIterState` hook', () => { } ); - it(gray("The state iterable's `.current.value` property is read-only"), async () => { + it(gray("The state iterable's `..value.current` property is read-only"), async () => { const [values] = renderHook(() => useAsyncIterState()).result.current; expect(() => { diff --git a/src/common/AsyncIterableChannel.ts b/src/common/AsyncIterableChannel.ts index 17a470e..c286278 100644 --- a/src/common/AsyncIterableChannel.ts +++ b/src/common/AsyncIterableChannel.ts @@ -59,7 +59,7 @@ class AsyncIterableChannel { /** * A stateful async iterable which will yield every updated value following an update. Includes a - * `.current.value` property which shows the current up to date state value. + * `.value.current` property which shows the current up to date state value. * * This is a shared async iterable - all iterators obtained from it share the same source values, * meaning that multiple iterators can be consumed (iterated) simultaneously and each one would pick up diff --git a/src/useAsyncIterState/index.ts b/src/useAsyncIterState/index.ts index 74a14fd..9ed22fe 100644 --- a/src/useAsyncIterState/index.ts +++ b/src/useAsyncIterState/index.ts @@ -43,14 +43,14 @@ export { useAsyncIterState, type AsyncIterStateResult, type AsyncIterableChannel * --- * * The returned async iterable can be passed over to any level down the component tree and rendered - * using ``, `useAsyncIter`, and others. It also contains a `.current.value` property which shows + * using ``, `useAsyncIter`, and others. It also contains a `.value.current` property which shows * the current up to date state value at all times. Use this any time you need to read the immediate * current state (for example as part of side effect logic) rather than directly rendering it, since * for rendering you may simply iterate values as part of an ``. * * Returned also alongside the async iterable is a function for updating the state. Calling it with a new * value will cause the paired iterable to yield the updated state value as well as immediately set the - * iterable's `.current.value` property to that new state. Just like + * iterable's `.value.current` property to that new state. Just like * [`React.useState`'s setter](https://react.dev/reference/react/useState#setstate), you can pass it * the next state directly, or a function that calculates it from the previous state. * @@ -62,7 +62,7 @@ export { useAsyncIterState, type AsyncIterStateResult, type AsyncIterableChannel * * @example * ```tsx - * // Use the state iterable's `.current.value` property to read the immediate current state: + * // Use the state iterable's `.value.current` property to read the immediate current state: * * import { useAsyncIterState } from 'react-async-iterators'; * @@ -73,8 +73,8 @@ export { useAsyncIterState, type AsyncIterStateResult, type AsyncIterableChannel * return ( *
{ - * const firstName = firstNameIter.current.value; - * const lastName = lastNameIter.current.value; + * const firstName = firstNameIter.value.current; + * const lastName = lastNameIter.value.current; * // submit `firstName` and `lastName`... * }} * > @@ -93,9 +93,9 @@ export { useAsyncIterState, type AsyncIterStateResult, type AsyncIterableChannel * --- * * @template TVal the type of state to be set and yielded by returned iterable. - * @template TInitVal The type of the starting value for the state iterable's `.current.value` property. + * @template TInitVal The type of the starting value for the state iterable's `.value.current` property. * - * @param initialValue Any optional starting value for the state iterable's `.current.value` property, defaults to `undefined`. You can pass an actual value, or a function that returns a value (which the hook will call once during mounting). + * @param initialValue Any optional starting value for the state iterable's `.value.current` property, defaults to `undefined`. You can pass an actual value, or a function that returns a value (which the hook will call once during mounting). * * @returns a stateful async iterable and a function with which to yield an update, both maintain stable references across re-renders. * @@ -146,7 +146,7 @@ type AsyncIterStateResult = [ /** * A stateful async iterable which yields every updated value following a state update. * - * Includes a `.current.value` property which shows the current up to date state value at all times. + * Includes a `.value.current` property which shows the current up to date state value at all times. * * This is a shared async iterable - all iterators obtained from it share the same source values, * meaning multiple iterators can be consumed (iterated) simultaneously, each one picking up the @@ -156,7 +156,7 @@ type AsyncIterStateResult = [ /** * A function which updates the state, causing the paired async iterable to yield the updated state - * value and immediately sets its `.current.value` property to the latest state. + * value and immediately sets its `.value.current` property to the latest state. */ setValue: (update: MaybeFunction) => void, ];