Skip to content

Commit 2c5481f

Browse files
committed
Clarify AsyncIterator use case in template return type guide
The previous description implied AsyncIterator was needed for any async work, which is wrong -- all template forms support async functions. The distinguishing characteristic is streaming/dynamic number of outputs.
1 parent fa212fe commit 2c5481f

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -884,9 +884,9 @@ Use the simplest return type that fits your needs:
884884
| String | No | No (derived from template filename) | Single file, filename from template name |
885885
| Object | No | Yes | Single file with a custom output path |
886886
| Array | Yes | Yes | Fixed set of output files known at build time |
887-
| AsyncIterator | Yes | Yes | Any async work, or a dynamic number of outputs |
887+
| AsyncIterator | Yes | Yes | Dynamic or unknown number of outputs at build time |
888888

889-
Start with a string return and only switch to a more complex type when you need what it provides. An async generator is the right choice when you need to do async work (such as calling `renderInnerPage` on multiple pages) and produce more than one output file.
889+
Start with a string return and only switch to a more complex type when you need what it provides. All template forms can do async work (string, object, and array all support `async` functions). Choose AsyncIterator specifically when the number of output files is not known until the template runs, or when you want to stream outputs one at a time rather than building the full list in memory first.
890890

891891
### RSS Feed Template Example
892892

0 commit comments

Comments
 (0)