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 6d4514f commit 1d0685fCopy full SHA for 1d0685f
typescript/packages/lookslike-high-level/src/recipes/counters.ts
@@ -9,7 +9,11 @@ const updateRandomItem = handler<
9
{},
10
{ items: { title: string; count: number }[] }
11
>(({}, state) => {
12
- state.items[Math.floor(Math.random() * state.items.length)].count += 1;
+ // TODO(ja): if a handler throws an exception recipes
13
+ // seems to stop updating / future handlers are not called.
14
+ if (state.items.length > 0) {
15
+ state.items[Math.floor(Math.random() * state.items.length)].count += 1;
16
+ }
17
});
18
19
const addItem = handler<{}, { items: { title: string; count: number }[] }>(
0 commit comments