Skip to content

Commit

Permalink
fixed bug with disconnect SSE
Browse files Browse the repository at this point in the history
  • Loading branch information
vazarkevych committed May 2, 2024
1 parent 73c437c commit d62e4a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Sources/CommonMain/Features/FeaturesViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ class FeaturesViewModel {
self?.prepareFeaturesData(data: jsonData)
}
streamingUpdate.connect()

streamingUpdate.onDissconnect { _, shouldReconnect, _ in
if let shouldReconnect = shouldReconnect, shouldReconnect {
streamingUpdate.connect()
}
}
}

/// Fetch Features
Expand Down
2 changes: 1 addition & 1 deletion Sources/CommonMain/Network/SSEHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ extension SSEHandler {
private func shouldReconnect(statusCode: Int) -> Bool {
switch statusCode {
case 200:
return false
return true
case _ where statusCode > 200 && statusCode < 300:
return true
default:
Expand Down

0 comments on commit d62e4a7

Please sign in to comment.