-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(events): close ws connection on unmount, catch and retry logic (#…
…1130) ## Done Refactored events code: - Close ws connection on unmount - Add catch and retry logic for ws connection failures - Refactored promises code
- Loading branch information
Showing
12 changed files
with
105 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
export const getPromiseSettledCounts = ( | ||
results: PromiseSettledResult<void>[], | ||
): { fulfilledCount: number; rejectedCount: number } => { | ||
const settledCounts = { fulfilledCount: 0, rejectedCount: 0 }; | ||
results.forEach((result) => { | ||
if (result.status === "fulfilled") { | ||
settledCounts.fulfilledCount++; | ||
} else if (result.status === "rejected") { | ||
settledCounts.rejectedCount++; | ||
} | ||
}); | ||
return settledCounts; | ||
}; | ||
|
||
export const pushSuccess = (results: PromiseSettledResult<void>[]): void => { | ||
results.push({ | ||
status: "fulfilled", | ||
value: undefined, | ||
}); | ||
}; | ||
|
||
export const pushFailure = ( | ||
results: PromiseSettledResult<void>[], | ||
msg: string, | ||
): void => { | ||
results.push({ | ||
status: "rejected", | ||
reason: msg, | ||
}); | ||
}; | ||
|
||
export const continueOrFinish = ( | ||
results: PromiseSettledResult<void>[], | ||
totalLength: number, | ||
resolve: (value: PromiseSettledResult<void>[]) => void, | ||
): void => { | ||
if (totalLength === results.length) { | ||
resolve(results); | ||
} | ||
}; |