Skip to content

Commit

Permalink
refactor: don't re-use index
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg authored and 0xpatrickdev committed Jul 1, 2024
1 parent 3d5a3f3 commit 1c0b964
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions packages/vow/src/watch-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,22 @@ export const prepareWatchUtils = (
const kit = makeVowKit();

// Preserve the order of the vow results.
let index = 0;
for (const vow of vows) {
watch(vow, this.facets.watcher, {
for (let index = 0; index < vows.length; index += 1) {
watch(vows[index], this.facets.watcher, {
id,
index,
numResults: vows.length,
});
index += 1;
}

if (index > 0) {
if (vows.length > 0) {
// Save the state until rejection or all fulfilled.
this.state.nextId += 1n;
idToVowState.init(
id,
harden({
resolver: kit.resolver,
remaining: index,
remaining: vows.length,
resultsMap: detached.mapStore('resultsMap'),
}),
);
Expand Down

0 comments on commit 1c0b964

Please sign in to comment.