SceneEvents.Update not triggered on beta5

arView.scene.subscribe(to: SceneEvents.Update.self) { event in } stop triggering on beta5.

Is there any changes on the usage of this subscriber?

I've been using this subscriber of ARView Scene for SceneEvents.Update from beta1 and was working normally til beta4.

Accepted Reply

There has been a change in Combine which aids in avoiding leaks, you will now need to hold a reference to the subscription like this:


class ViewController: UIViewController {
   
    @IBOutlet var arView: ARView!
   
    var sceneEventsUpdateSubscription: Cancellable!
   
    override func viewDidLoad() {
        super.viewDidLoad()
       
        sceneEventsUpdateSubscription = arView.scene.subscribe(to: SceneEvents.Update.self) { [unowned self] (_) in
            self.updateScene()
        }
       
    }

Replies

There has been a change in Combine which aids in avoiding leaks, you will now need to hold a reference to the subscription like this:


class ViewController: UIViewController {
   
    @IBOutlet var arView: ARView!
   
    var sceneEventsUpdateSubscription: Cancellable!
   
    override func viewDidLoad() {
        super.viewDidLoad()
       
        sceneEventsUpdateSubscription = arView.scene.subscribe(to: SceneEvents.Update.self) { [unowned self] (_) in
            self.updateScene()
        }
       
    }

Thanks, it is working again as expected!