Skip to content

Instantly share code, notes, and snippets.

@serhiybutz
Last active July 31, 2020 04:23
Show Gist options
  • Save serhiybutz/49f7fefa4d7dc42d63b1e72b4a39d886 to your computer and use it in GitHub Desktop.
Save serhiybutz/49f7fefa4d7dc42d63b1e72b4a39d886 to your computer and use it in GitHub Desktop.
protocol TargetAction {
func applyTheme(_ theme: MyTheme)
}
struct AnyTargetActionWrapper<T: AnyObject>: TargetAction {
weak var target: T?
let action: (T) -> (MyTheme) -> ()
func applyTheme(_ theme: MyTheme) -> () {
if let t = target {
action(t)(theme)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment