diff --git a/src/MaybeAsyncIterable/index.ts b/src/MaybeAsyncIterable/index.ts new file mode 100644 index 0000000..181f2c9 --- /dev/null +++ b/src/MaybeAsyncIterable/index.ts @@ -0,0 +1,26 @@ +export { MaybeAsyncIterable }; + +/** + * Helper type that represents either a plain value or an async iterable of that value. + * + * This type is useful among else for typing props for components that can accept either a + * _"static" value_ or a _"changing" value_ (an async iterable) seamlessly. + * + * @example + * ```tsx + * import { It, type MaybeAsyncIterable } from 'react-async-iterators'; + * + * function MyComponent(props: { values: MaybeAsyncIterable }) { + * return ( + * + * ); + * } + * ``` + */ +type MaybeAsyncIterable = T | AsyncIterable;