Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extension Publisher where Failure == Never{
- func present<ToVC:UIViewController, P>(from fromVC:UIViewController,
- to toVC:ToVC,
- assignee: KeyPath<ToVC, P>,
- keyPath: ReferenceWritableKeyPath<P,Output>,
- animated:Bool = true) -> AnyCancellable {
- sink {[weak fromVC, weak toVC] (output) in
- guard let to = toVC, let from = fromVC else {return}
- let toBeAssign = to[keyPath: assignee]
- toBeAssign[keyPath: keyPath] = output
- from.present(to, animated: true, completion: nil)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement