Skip to content

Commit

Permalink
Merge pull request ReactiveX#1086 from radex/rx-examples-back
Browse files Browse the repository at this point in the history
[RxExamples] Simplify disposal in GitHubSignup
  • Loading branch information
kzaher authored Jan 31, 2017
2 parents 4d13a98 + 2bbc478 commit 5f8ce36
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,4 @@ class GitHubSignupViewController2 : ViewController {
.disposed(by: disposeBag)
view.addGestureRecognizer(tapBackground)
}

// This is one of the reasons why it's a good idea for disposal to be detached from allocations.
// If resources weren't disposed before view controller is being deallocated, signup alert view
// could be presented on top of the wrong screen or could crash your app if it was being presented
// while navigation stack is popping.

// This will work well with UINavigationController, but has an assumption that view controller will
// never be added as a child view controller. If we didn't recreate the dispose bag here,
// then our resources would never be properly released.
override func willMove(toParentViewController parent: UIViewController?) {
if let parent = parent {
assert(parent as? UINavigationController != nil, "Please read comments")
}
else {
self.disposeBag = DisposeBag()
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -81,24 +81,4 @@ class GitHubSignupViewController1 : ViewController {
.disposed(by: disposeBag)
view.addGestureRecognizer(tapBackground)
}

// This is one of the reasons why it's a good idea for disposal to be detached from allocations.
// If resources weren't disposed before view controller is being deallocated, signup alert view
// could be presented on top of the wrong screen or could crash your app if it was being presented
// while navigation stack is popping.

// This will work well with UINavigationController, but has an assumption that view controller will
// never be added as a child view controller. If we didn't recreate the dispose bag here,
// then our resources would never be properly released.
override func willMove(toParentViewController parent: UIViewController?) {
if let parent = parent {
if parent as? UINavigationController == nil {
assert(false, "something")
}
}
else {
self.disposeBag = DisposeBag()
}
}

}

0 comments on commit 5f8ce36

Please sign in to comment.