Skip to content
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
2 changes: 1 addition & 1 deletion src/MaybeAsyncIterable/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { MaybeAsyncIterable };
export { type MaybeAsyncIterable };

/**
* Helper type that represents either a plain value or an async iterable of that value.
Expand Down
4 changes: 2 additions & 2 deletions src/iterateFormatted/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { type Iterate } from '../Iterate/index.js'; // eslint-disable-line @type
export { iterateFormatted };

/**
* An optional utility to format an async iterable's values inline right where its passing into
* An optional utility to format an async iterable's values inline where its passed into
* an other consuming component.
*
* @example
Expand Down Expand Up @@ -57,7 +57,7 @@ export { iterateFormatted };
* of far from it, having to perform the transformation using some `useMemo` call at the top of the
* component.
*
* The utility's method of operation is it will take `source` and return from it a new transformed
* The utility's method of operation is to be given a `source` and return from it a new transformed
* async iterable object, attaching it with some special metadata that tells library tools like
* {@link Iterate `<Iterate>`} and {@link useAsyncIter `useAsyncIter`} to bind the iteration process
* to the same original base object. This way, the outer "formatted" iterable may be recreated repeatedly
Expand Down
3 changes: 3 additions & 0 deletions src/useAsyncIter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ type IterationResult<TVal, TInitVal = undefined> = {
*
* When the source iterable changes and an iteration restarts with a new iterable, the same last
* `value` is carried over and reflected until the new iterable resolves its first value.
*
* If the async iteration has completed or errored out, `value` would still hold the last
* value it picked up but now the accompanying `done` and `error` will be set accordingly.
* */
value: TVal extends AsyncIterableSubject<infer J>
? J
Expand Down
25 changes: 13 additions & 12 deletions src/useAsyncIterState/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ export { useAsyncIterState, type AsyncIterStateResult, type AsyncIterableChannel
* ```tsx
* // Quick usage:
*
* import { useAsyncIterState, Iterate } from 'async-react-iterators';
* import { useAsyncIterState, Iterate } from 'react-async-iterators';
*
* function MyForm() {
* const [firstNameIter, setFirstName] = useAsyncIterState<string>();
* const [lastNameIter, setLastName] = useAsyncIterState<string>();
* const [firstNameIter, setFirstName] = useAsyncIterState('');
* const [lastNameIter, setLastName] = useAsyncIterState('');
* return (
* <div>
* <form>
Expand All @@ -43,9 +43,10 @@ export { useAsyncIterState, type AsyncIterStateResult, type AsyncIterableChannel
* ---
*
* The returned async iterable can be passed over to any level down the component tree and rendered
* using `<Iterate>`, `useAsyncIter`, and so on. It also contains a `.current.value` property which shows
* the current up to date state value at all times. Use this any case you just need to read the immediate
* current state rather than directly rendering it, since for rendering you may simply async-iterate it.
* using `<Iterate>`, `useAsyncIter`, and others. It also contains a `.current.value` 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 `<Iterate>`.
*
* 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
Expand All @@ -55,19 +56,19 @@ export { useAsyncIterState, type AsyncIterStateResult, type AsyncIterableChannel
*
* Unlike vanila `React.useState`, which simply re-renders the entire component - `useAsyncIterState`
* helps confine UI updates by handing you an iterable which choose how and where in the component tree
* to render it. This work method can facilitate layers of sub-components that pass actual async iterables
* across one another as props, skipping typical cascading re-renderings down to __only the inner-most
* leafs__ of the UI tree.
* to render it. This method of working can facilitate layers of sub-components that pass actual async
* iterables down to one another as props, avoiding typical cascading re-renderings, updating __only
* the inner-most leafs__ in the UI tree instead.
*
* @example
* ```tsx
* // Use the state iterable's `.current.value` property to read the immediate current state:
*
* import { useAsyncIterState } from 'async-react-iterators';
* import { useAsyncIterState } from 'react-async-iterators';
*
* function MyForm() {
* const [firstNameIter, setFirstName] = useAsyncIterState<string>();
* const [lastNameIter, setLastName] = useAsyncIterState<string>();
* const [firstNameIter, setFirstName] = useAsyncIterState('');
* const [lastNameIter, setLastName] = useAsyncIterState('');
*
* return (
* <form
Expand Down
Loading