Skip to content

Commit 9ad4aeb

Browse files
authored
docs: various docs touchups (#62)
1 parent 433d978 commit 9ad4aeb

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

src/MaybeAsyncIterable/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export { MaybeAsyncIterable };
1+
export { type MaybeAsyncIterable };
22

33
/**
44
* Helper type that represents either a plain value or an async iterable of that value.

src/iterateFormatted/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { type Iterate } from '../Iterate/index.js'; // eslint-disable-line @type
1313
export { iterateFormatted };
1414

1515
/**
16-
* An optional utility to format an async iterable's values inline right where its passing into
16+
* An optional utility to format an async iterable's values inline where its passed into
1717
* an other consuming component.
1818
*
1919
* @example
@@ -57,7 +57,7 @@ export { iterateFormatted };
5757
* of far from it, having to perform the transformation using some `useMemo` call at the top of the
5858
* component.
5959
*
60-
* The utility's method of operation is it will take `source` and return from it a new transformed
60+
* The utility's method of operation is to be given a `source` and return from it a new transformed
6161
* async iterable object, attaching it with some special metadata that tells library tools like
6262
* {@link Iterate `<Iterate>`} and {@link useAsyncIter `useAsyncIter`} to bind the iteration process
6363
* to the same original base object. This way, the outer "formatted" iterable may be recreated repeatedly

src/useAsyncIter/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ type IterationResult<TVal, TInitVal = undefined> = {
212212
*
213213
* When the source iterable changes and an iteration restarts with a new iterable, the same last
214214
* `value` is carried over and reflected until the new iterable resolves its first value.
215+
*
216+
* If the async iteration has completed or errored out, `value` would still hold the last
217+
* value it picked up but now the accompanying `done` and `error` will be set accordingly.
215218
* */
216219
value: TVal extends AsyncIterableSubject<infer J>
217220
? J

src/useAsyncIterState/index.ts

+13-12
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ export { useAsyncIterState, type AsyncIterStateResult, type AsyncIterableChannel
2222
* ```tsx
2323
* // Quick usage:
2424
*
25-
* import { useAsyncIterState, Iterate } from 'async-react-iterators';
25+
* import { useAsyncIterState, Iterate } from 'react-async-iterators';
2626
*
2727
* function MyForm() {
28-
* const [firstNameIter, setFirstName] = useAsyncIterState<string>();
29-
* const [lastNameIter, setLastName] = useAsyncIterState<string>();
28+
* const [firstNameIter, setFirstName] = useAsyncIterState('');
29+
* const [lastNameIter, setLastName] = useAsyncIterState('');
3030
* return (
3131
* <div>
3232
* <form>
@@ -43,9 +43,10 @@ export { useAsyncIterState, type AsyncIterStateResult, type AsyncIterableChannel
4343
* ---
4444
*
4545
* The returned async iterable can be passed over to any level down the component tree and rendered
46-
* using `<Iterate>`, `useAsyncIter`, and so on. It also contains a `.current.value` property which shows
47-
* the current up to date state value at all times. Use this any case you just need to read the immediate
48-
* current state rather than directly rendering it, since for rendering you may simply async-iterate it.
46+
* using `<Iterate>`, `useAsyncIter`, and others. It also contains a `.current.value` property which shows
47+
* the current up to date state value at all times. Use this any time you need to read the immediate
48+
* 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>`.
4950
*
5051
* Returned also alongside the async iterable is a function for updating the state. Calling it with a new
5152
* value will cause the paired iterable to yield the updated state value as well as immediately set the
@@ -55,19 +56,19 @@ export { useAsyncIterState, type AsyncIterStateResult, type AsyncIterableChannel
5556
*
5657
* Unlike vanila `React.useState`, which simply re-renders the entire component - `useAsyncIterState`
5758
* helps confine UI updates by handing you an iterable which choose how and where in the component tree
58-
* to render it. This work method can facilitate layers of sub-components that pass actual async iterables
59-
* across one another as props, skipping typical cascading re-renderings down to __only the inner-most
60-
* leafs__ of the UI tree.
59+
* to render it. This method of working can facilitate layers of sub-components that pass actual async
60+
* iterables down to one another as props, avoiding typical cascading re-renderings, updating __only
61+
* the inner-most leafs__ in the UI tree instead.
6162
*
6263
* @example
6364
* ```tsx
6465
* // Use the state iterable's `.current.value` property to read the immediate current state:
6566
*
66-
* import { useAsyncIterState } from 'async-react-iterators';
67+
* import { useAsyncIterState } from 'react-async-iterators';
6768
*
6869
* function MyForm() {
69-
* const [firstNameIter, setFirstName] = useAsyncIterState<string>();
70-
* const [lastNameIter, setLastName] = useAsyncIterState<string>();
70+
* const [firstNameIter, setFirstName] = useAsyncIterState('');
71+
* const [lastNameIter, setLastName] = useAsyncIterState('');
7172
*
7273
* return (
7374
* <form

0 commit comments

Comments
 (0)