Skip to content

Commit

Permalink
feat: make sure that all completion handlers have been called
Browse files Browse the repository at this point in the history
  • Loading branch information
pklatka committed Apr 22, 2024
1 parent 820ec9e commit c1491c2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/turbo/ios/RNVisitableView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ extension RNVisitableView: RNVisitableViewControllerDelegate {
func visitableDidAppear(visitable: Visitable) {
session.visitableViewDidAppear(view: self)
}

func visitableWillDisappear(visitable: Visitable) {
// Make sure that all completion handlers have been called.
// Otherwise we might end up with a NSInternalInconsistencyException.
sendAlertResult()
sendConfirmResult(result: "")
}

func visitableDidDisappear(visitable: Visitable) {
// No-op
Expand Down
7 changes: 7 additions & 0 deletions packages/turbo/ios/RNVisitableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public protocol RNVisitableViewControllerDelegate {
func visitableDidAppear(visitable: Visitable)

func visitableDidRender(visitable: Visitable)

func visitableWillDisappear(visitable: Visitable)

func visitableDidDisappear(visitable: Visitable)

Expand Down Expand Up @@ -56,6 +58,11 @@ class RNVisitableViewController: UIViewController, Visitable {
delegate?.visitableDidAppear(visitable: self)
}

override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
delegate?.visitableWillDisappear(visitable: self)
}

override func viewDidDisappear(_ animated: Bool) {
delegate?.visitableDidDisappear(visitable: self)
}
Expand Down

0 comments on commit c1491c2

Please sign in to comment.