Skip to content

Instantly share code, notes, and snippets.

@muizidn
Last active August 10, 2019 05:51
Show Gist options
  • Save muizidn/137b954fd4e21a92821ece4091e17517 to your computer and use it in GitHub Desktop.
Save muizidn/137b954fd4e21a92821ece4091e17517 to your computer and use it in GitHub Desktop.
Make autocompletion gives you better result when assign closure
/// Eg: Closure<(Int) -> Void>
struct Closure<T> {
let closure: T
}
class LoginView: UIView {
var appereanceConfig: Closure<(UIStackView)->Void> = .init { _ in }
private stackView: UIStackView()
convenience init() {
self.init(frame: .zero)
appereanceConfig.closure(stackView)
}
}
let v = LoginView()
// Was
// Here we don't get good completion
v.appereanceConfig = { stack in
}
// But now its better
v.appereanceConfig = .init { stack in
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment