Skip to content

Instantly share code, notes, and snippets.

@eito

eito/issue.swift Secret

Created October 17, 2020 06:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eito/42cf5bff80f8c20d06342750ef06cb94 to your computer and use it in GitHub Desktop.
Save eito/42cf5bff80f8c20d06342750ef06cb94 to your computer and use it in GitHub Desktop.
@objc
func doStuff() {
foo { [weak self] in
guard let mySelf = self else {
return
}
// uncomment this and this code doesn't cause a leak
//
// mySelf.barAsync {
// mySelf.bar()
// }
// uncomment this and the call to mySelf.bar() causes a leak
//
mySelf.settings.$isEnabled
.dropFirst()
.sink { _ in
mySelf.bar()
}
.store(in: &mySelf.subscriptions)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment