You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/useAsyncIterState/index.ts
+10-10
Original file line number
Diff line number
Diff line change
@@ -12,11 +12,13 @@ export { useAsyncIterState, type AsyncIterStateResult, type AsyncIterableChannel
12
12
13
13
/**
14
14
* Basically like {@link https://react.dev/reference/react/useState `React.useState`}, only that the value
15
-
* is provided back __wrapped as an async iterable__.
15
+
* is provided back __wrapped in an async iterable__.
16
16
*
17
-
* This hook allows a component to declare and manage a piece of state while easily letting you control
18
-
* what specifically area(s) within the UI should be bound to it (should re-render in reaction to changes
19
-
* in it) - for example, if combined with one or more {@link Iterate `<Iterate>`}s.
17
+
* This hook allows a component to declare and manage a piece of state as an async iterable thus
18
+
* letting you easily control what specific places in the app UI tree should be bound to it,
19
+
* re-rendering in reaction to its changes (if used in conjunction with {@link Iterate `<Iterate>`}
20
+
* for example).
21
+
20
22
*
21
23
* @example
22
24
* ```tsx
@@ -44,9 +46,9 @@ export { useAsyncIterState, type AsyncIterStateResult, type AsyncIterableChannel
44
46
*
45
47
* The returned async iterable can be passed over to any level down the component tree and rendered
46
48
* using `<Iterate>`, `useAsyncIter`, and others. It also contains a `.value.current` property which shows
47
-
* the current up to date state value at all times. Use this any time you need to read the immediate
49
+
* the current up to date state value at any time. Use this any time you need to read the immediate
48
50
* current state (for example as part of side effect logic) rather than directly rendering it, since
49
-
* for rendering you may simply iterate values as part of an `<Iterate>`.
51
+
* for rendering you may simply iterate the values as part of an `<Iterate>`.
50
52
*
51
53
* Returned also alongside the async iterable is a function for updating the state. Calling it with a new
52
54
* value will cause the paired iterable to yield the updated state value as well as immediately set the
@@ -84,9 +86,7 @@ export { useAsyncIterState, type AsyncIterStateResult, type AsyncIterableChannel
84
86
* }
85
87
* ```
86
88
*
87
-
* The returned async iterable is a shared iterable - can be iterated by multiple consumers simultaneously
88
-
* (e.g multiple {@link Iterate `<Iterate>`}s) and each would pick up the same yielded values and at the
89
-
* same time.
89
+
* The returned async iterable is a shared iterable so that if iterated by multiple consumers simultaneously (e.g multiple {@link Iterate `<Iterate>`}s) then all would pick up the same yields at the same time.
90
90
*
91
91
* The returned async iterable is automatically closed on host component unmount.
92
92
*
@@ -97,7 +97,7 @@ export { useAsyncIterState, type AsyncIterStateResult, type AsyncIterableChannel
97
97
*
98
98
* @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).
99
99
*
100
-
* @returns a stateful async iterable and a function with which to yield an update, both maintain stable references across re-renders.
100
+
* @returns a stateful async iterable and a function for yielding an update. Both maintain stable references across re-renders.
0 commit comments