We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a782813 commit 3cd7dd8Copy full SHA for 3cd7dd8
docs/how-to-reduce-your-spend.mdx
@@ -104,12 +104,10 @@ Sometimes it's more efficient to do more work in a single task than split across
104
export const processItems = task({
105
id: "process-items",
106
run: async (payload: { items: string[] }) => {
107
- // Process all items in one run
108
- for (const item of payload.items) {
109
- // Do async work in parallel
110
- // This works very well for API calls
111
- await processItem(item);
112
- }
+ // Process all items in parallel
+ const promises = payload.items.map(item => processItem(item));
+ // This works very well for API calls
+ await Promise.all(promises);
113
},
114
});
115
```
0 commit comments