Closed heyltsjay closed 6 years ago
your FWIW is definitely W
Are you concerned about making ownership mistakes, deviating from UIKit, not enough of a win, all of the above?
Ownership mistakes yes (we both saw them come out of the woodwork on this last project), and not enough of a win. In fact, I think in many cases it harms readability over having a separate method. Stuff like this from that same recent project is an example of both:
button.callback = { [weak self, unowned button] in
self?.notify(.action(from: button))
}
I made the same argument with RZDataBinding which is why that followed target/action paradigm.
I'm pretty compelled by the happy path, where convenience methods can vend in weak closures
skipButton.callback = notify(.skip)
But I agree that things got pretty icky when multiple block-based APIs started nesting inside one another.
If you don't self?.notify(.skip)
you've caused a retain cycle 😬
Edit: Oh you mean the extension on Actionable
. Is that in the template?
well, you're going to hate it but, no because of:
extension Actionable {
func notify(_ action: ActionType) -> () -> Void {
return { [weak self] in
self?.notify(action)
}
}
I think this conversation has convinced me that this doesn't need to go in. Easy enough for folks to pull in if they choose.
FWIW I'm against blockified UIControls