Skip to content

Commit

Permalink
Merge pull request #19 from maxxfrazer/weak
Browse files Browse the repository at this point in the history
- Set ARView reference to weak
  • Loading branch information
maxxfrazer authored Apr 1, 2021
2 parents 9975eb6 + 27982ea commit a8de187
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions Sources/FocusEntity/FocusEntity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ open class FocusEntity: Entity, HasAnchoring, HasFocusEntity {
self.arView?.scene
}

internal var arView: ARView?
internal weak var arView: ARView?

/// For moving the FocusEntity to a whole new ARView
/// - Parameter view: The destination `ARView`
Expand Down Expand Up @@ -83,18 +83,15 @@ open class FocusEntity: Entity, HasAnchoring, HasFocusEntity {
public private(set) var isAutoUpdating: Bool = false

public func setAutoUpdate(to autoUpdate: Bool) {
if autoUpdate == self.isAutoUpdating {
return
}
if self.arView == nil {
guard autoUpdate == self.isAutoUpdating,
(autoUpdate && self.arView == nil) else {
return
}
self.updateCancellable?.cancel()
if autoUpdate {
self.updateCancellable = self.myScene?.subscribe(
to: SceneEvents.Update.self, self.updateFocusEntity
)
} else {
self.updateCancellable?.cancel()
}
self.isAutoUpdating = autoUpdate
}
Expand Down

0 comments on commit a8de187

Please sign in to comment.