File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -292,6 +292,17 @@ public class LiveSessionCoordinator<R: RootRegistry>: ObservableObject {
292292 }
293293 }
294294
295+ func overrideLiveReloadChannel( channel: LiveChannel ) async throws {
296+
297+ if let liveReloadChannel {
298+ try await liveReloadChannel. shutdownParentSocket ( )
299+ self . liveReloadChannel = nil
300+ }
301+
302+ self . liveReloadChannel = channel
303+ self . bindLiveReloadListener ( )
304+ }
305+
295306 func bindLiveReloadListener( ) {
296307 let eventListener = self . liveReloadChannel!. channel ( ) . events ( )
297308 self . liveReloadListenerLoop = Task { @MainActor [ weak self] in
Original file line number Diff line number Diff line change 88import Foundation
99import SwiftUI
1010import Combine
11+ import LiveViewNativeCore
1112
1213/// Create a ``LiveView`` with a list of addons.
1314///
@@ -206,6 +207,16 @@ public struct LiveView<
206207 case . connecting:
207208 return . connecting
208209 case let . connectionFailed( error) :
210+
211+ if let error = error as? LiveViewNativeCore . LiveSocketError ,
212+ case let . ConnectionError( connectionError) = error {
213+ if let channel = connectionError. livereloadChannel {
214+ Task { @MainActor [ weak session] in
215+ try await session? . overrideLiveReloadChannel ( channel: channel)
216+ }
217+ }
218+ }
219+
209220 return . error( error)
210221 case . setup:
211222 return . connecting
You can’t perform that action at this time.
0 commit comments