-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove retain cycle in the examples #23
Conversation
Self was strongly referenced in most of the examples, thus creating a dependency cycle. This could easy be verified by checking the #debug logs: isDisposed was never called when navigating back from the controllers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! I'd just want to use self instead of strongSelf.
@@ -25,10 +25,11 @@ class FailedRequestViewController: UIViewController { | |||
.didFailProvisionalNavigation | |||
.observeOn(MainScheduler.instance) | |||
.debug("didFailProvisionalNavigation") | |||
.subscribe(onNext: {(webView, navigation, error) in | |||
.subscribe(onNext: { [weak self] webView, navigation, error in | |||
guard let strongSelf = self else { return } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you do
guard let strongSelf = self else { return } | |
guard let self = self else { return } |
As available since Swift 4.2 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
This is possible since Swift 4.2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Thanks a lot for contributing @NeverwinterMoon! I've invited you to join the Generated by 🚫 dangerJS |
Self was strongly referenced in most of the examples, thus creating a dependency cycle. This could easy be verified by checking the #debug logs: isDisposed was never called when navigating back from the controllers.
Considering that people will use the examples as a reference, it seems weird to leave it as it was.