@@ -52,7 +52,6 @@ public final class BridgeDelegate: BridgingDelegate {
5252 public func webViewDidBecomeActive( _ webView: WKWebView ) {
5353 bridge = Bridge . getBridgeFor ( webView)
5454 bridge? . delegate = self
55- destinationIsActive = true
5655
5756 if bridge == nil {
5857 logger. warning ( " bridgeNotInitializedForWebView " )
@@ -62,7 +61,6 @@ public final class BridgeDelegate: BridgingDelegate {
6261 public func webViewDidBecomeDeactivated( ) {
6362 bridge? . delegate = nil
6463 bridge = nil
65- destinationIsActive = false
6664 }
6765
6866 @discardableResult
@@ -84,19 +82,16 @@ public final class BridgeDelegate: BridgingDelegate {
8482
8583 public func onViewDidLoad( ) {
8684 logger. debug ( " [Bridge] bridgeDestinationViewDidLoad: \( self . resolvedLocation) " )
87- destinationIsActive = true
8885 activeComponents. forEach { $0. viewDidLoad ( ) }
8986 }
9087
9188 public func onViewWillAppear( ) {
9289 logger. debug ( " [Bridge] bridgeDestinationViewWillAppear: \( self . resolvedLocation) " )
93- destinationIsActive = true
9490 activeComponents. forEach { $0. viewWillAppear ( ) }
9591 }
9692
9793 public func onViewDidAppear( ) {
9894 logger. debug ( " [Bridge] bridgeDestinationViewDidAppear: \( self . resolvedLocation) " )
99- destinationIsActive = true
10095 activeComponents. forEach { $0. viewDidAppear ( ) }
10196 }
10297
@@ -107,7 +102,6 @@ public final class BridgeDelegate: BridgingDelegate {
107102
108103 public func onViewDidDisappear( ) {
109104 activeComponents. forEach { $0. viewDidDisappear ( ) }
110- destinationIsActive = false
111105 logger. debug ( " [Bridge] bridgeDestinationViewDidDisappear: \( self . resolvedLocation) " )
112106 }
113107
@@ -147,14 +141,20 @@ public final class BridgeDelegate: BridgingDelegate {
147141 // MARK: Private
148142
149143 private var initializedComponents : [ String : BridgeComponent ] = [ : ]
150- private var destinationIsActive = false
151144 private let componentTypes : [ BridgeComponent . Type ]
145+ private var destinationIsActive : Bool {
146+ bridge != nil
147+ }
152148 private var resolvedLocation : String {
153149 webView? . url? . absoluteString ?? location
154150 }
155151
156152 private var activeComponents : [ BridgeComponent ] {
157- return initializedComponents. values. filter { _ in destinationIsActive }
153+ guard destinationIsActive else {
154+ return [ ]
155+ }
156+
157+ return Array ( initializedComponents. values)
158158 }
159159
160160 private func getOrCreateComponent( name: String ) -> BridgeComponent ? {
0 commit comments